SAS macro function to get file modified date on linux

Asked
Active3 hr before
Viewed126 times

4 Answers

function
90%

That doesn't happen on Windows, at least. I get a nice SAS datetime.,Would appreciate thoughts on better ways to convert the date string to a SAS date, better ways to get the file modified date, and any pitfalls to below., Applying to math graduate schools. Should I submit a letter of recommendation from a physics professor? , Will this Account Lockout mechanism increase the severity of a information leakage vulnerability that leaks usernames?

Adding some debugging:

% macro GetModDate(file); %
* Get the modified date of a linux file, as SAS date; %
local rc fref fid ModDate;

%
let rc = % sysfunc(filename(fref, & file)); %
put &= rc; %
let fid = % sysfunc(fopen( & fref)); %
put &= fid; %
let ModDate = % sysfunc(finfo( & fid, Last Modified)); %
put &= ModDate; %
* Linux Last Modified returns format like: Fri Apr 10 14: 54: 10 2015; %
let ModDate = % sysfunc(inputn( % scan( & moddate, 2, % str()) % scan( & moddate, 3, % str()) % scan( & moddate, 5, % str()), anydtdte11)); %
let fid = % sysfunc(fclose( & fid)); %
let rc = % sysfunc(filename(fref));

&
ModDate
   %
   mend GetModDate;

%
getModDate(c: \temp\ test.html)
load more v
88%

Hi, I am trying to get the last date modified for an EXCEL sheet, however the returned value is blank not sure why. I am running the following bit of code on SAS 9.4.,Calling all SAS users! We now have even more FREE knowledge journeys. From DevOps and Data Science to Fraud and Risk, our journeys contain expert advice and tips for getting the most from SAS. Learn more.,This worked, I added a bit of code to change the format though,Need further help from the community? Please sign in and ask a new question.

 

%
let specname = XXX99999 Mapping v0 .1;

%
let rc = % sysfunc(filename(onefile, % str(.\Docs\ & specname..xls)))); %
let fid = % sysfunc(fopen( & onefile.)); %
let modifydt = % sysfunc(finfo( & fid, Last Modified)); %
let fidc = % sysfunc(fclose( & fid.)); %
let rc = % sysfunc(filename(onefile));

 

SYMBOLGEN: Macro variable MODIFYDT resolves to
load more v
72%

Retrieve file size or last modified date of an external file – The FINFO functions return the value of a file specified. You can get six attributes named ‘info items’ through the use of the FINFO function.,Read More Importing multiple Excel files to create a single SAS datasetContinue ,Importing multiple Excel files to create a single SAS dataset,6 methods to reorder Variables in SAS Data Set

data a(drop = fid);
infile fileref truncover obs = 1;
fid = fopen('fileref');
Bytes = finfo(fid, 'File Size (bytes)');
crdate = finfo(fid, 'Create Time');
moddate = finfo(fid, 'Last Modified');
run;
load more v
65%

This does not happen on Windows at least. I get a good time and SAS time.,Adding some debugging:,Trying to get file attributes (file size, date creation time and last modified time) in SAS - sas,I would read thoughts about the best ways to convert a date string to a SAS date, the best ways to get the file modification date and any errors below.

I would read thoughts about the best ways to convert a date string to a SAS date, the best ways to get the file modification date and any errors below.

% macro GetModDate(file); %
* Get the modified date of a linux file, as SAS date; %
local rc fref fid ModDate;

%
let rc = % sysfunc(filename(fref, & file)); %
let fid = % sysfunc(fopen( & fref));

%
let ModDate = % sysfunc(finfo( & fid, Last Modified));

%
* Linux Last Modified returns format like: Fri Apr 10 14: 54: 10 2015; %
let ModDate = % sysfunc(inputn( % scan( & moddate, 2, % str()) % scan( & moddate, 3, % str()) % scan( & moddate, 5, % str()), anydtdte11)); %
let fid = % sysfunc(fclose( & fid)); %
let rc = % sysfunc(filename(fref));

&
ModDate
   %
   mend GetModDate;
load more v

Other "function-undefined" queries related to "SAS macro function to get file modified date on linux"