I recently came across your solution post about how to get the list of the files in a folder using the SAS functions. Extension to that request, I would like to get the last modified or created dates of those files as variable in my dataset. Is there any SAS function that will helps us to get it? I am sorry if this question already answered ( unfortunately I could not find it). Here is the old post and solution link (thanks to @Kurt_Bremser ).
Old post link:https://communities.sas.com/t5/SAS-Programming/How-to-List-all-the-files-in-a-folder/td-p/674065
data filenames;
length fref $8 fname $200;
did = filename(fref,'&path');
did = dopen(fref);
do i = 1 to dnum(did);
fname = dread(did,i);
output;
end;
did = dclose(did);
did = filename(fref);
keep fname;
run;
For every file found, define a FILENAME like for the directory (use a different fref variable). Use FOPEN to open the file, then you can use the FOPTNUM, FOPTNAME and FINFO functions to get the file metadata. Read the relevant documentations for this.
For every file found, define a FILENAME like for the directory (use a different fref variable). Use FOPEN to open the file, then you can use the FOPTNUM, FOPTNAME and FINFO functions to get the file metadata. Read the relevant documentations for this.
Or try dictionary table.
filename x1 'c:\temp\class.txt';
filename x2 'c:\temp\subtitle.txt';
proc sql;
select * from dictionary.EXTFILES
where Fileref in ('X1' 'X2');
quit;
Thank you
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.