A number of ways.
Completely in SAS you can use a combination of SAS external file functions:
https://documentation.sas.com/doc/en/imlcdc/14.2/imlug/imlug_langref_sect561.htm
Or you can use X command/filename pipe to execute a dir/ls command to retrieve that information.
I read it all but unable to use it, Although what I found using google says the physical file does not exist but its there in my network folder. And I am able to import that same file using proc import
The below is my code:
%let filepath = /SAS_library/NAS_CA/QR/QR/Import_file/MERMAST_INFILE.csv;
data _null_;
lastmod = attrn("&filepath.", "LM");
put "Last Modified Date: " lastmod datetime.;
run;
Please suggest what I should Do. Is there any solution for this.
Is the file in question a SAS data set, other SAS file or something external to SAS such as a text file read for data?
Its not a SAS data set its an external CSV file in my network folder.
Just to be clear I am able to import that CSV file using proc import. The task here for me is to check if the dumped file has last modified date of today then I want to schedule that job.
How about using BasePlus package and the dirsAndFiles macro?
%dirsAndFiles(
</path/to/your/directory>
,ODS=work.outputDataSet
,keepDirs=0 /* ignore directories */
,details=1 /* get details */
,maxDepth=1 /* don't look in subdirectories */
)
And then use "LastModified" variable.
All the best
Bart
P.S. To install and use basePlus package do:
filename SPFinit url "https://raw.githubusercontent.com/yabwon/SAS_PACKAGES/main/SPF/SPFinit.sas";
%include SPFinit; /* enable the framework */filename packages "</your/directory/for/packages/>";
%installPackage(SPFinit basePlus) filename packages "</your/directory/for/packages/>";
%include packages(SPFinit.sas);
%loadPackage(basePlus)
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.