Hello to every one! I have a report in SAS that reads few .txt files that are distinguished from the date of the last refresh i.e 20220516_filenameabc 20220509_filenameabc 20220502_filenameabc With the scripts below I was able to extract the latest refresh: data filenames;
length fref $8 fname $200;
did = filename(fref,'path\Automated Extracts');
did = dopen(fref);
do i = 1 to dnum(did);
fname = dread(did,i);
output;
end;
did = dclose(did);
did = filename(fref);
keep fname;
run;
data latest;
set filenames;
length ldate $8 ;
ldate = substr(fname, 1,8);
if substr (ldate ,1,1) ~= 2 then delete ;
drop fname ;
run;
proc sort data = latest;
by descending ldate ; run;
proc sort nodupkey data = latest;
by descending ldate ; run;
data latestd ;
set latest (OBS=1 FirstOBS=1) ; run ; The part that I want to automate is this: %LET INDATAFILE7 = 'path\Automated Extracts\20220516_filenameabc.txt'; Instead of manually updating here 20220516 to use a macro that reads this from the dataset created with the above script so I don't need to go every time that I run the report to check the latest file and manually change that part! Any suggestion what I can do better here? Thanks for your time and support!
... View more