Hi, looking for some help as how to apply the derived variable values from file names. I feel like there is an easy macro to do this and my mind is just not going there. This code generates two variables - one with the path/filename the other the corresponding file date. I want to insert the file date value with the dataset of the corresponding file name as a variable to be associated with each observation in the particular file. filename examples xxxxxxxxxxxxxxxx_dec2018 xxxxxxxxxxxxxxxx_jan2019 xxxxxxxxxxxxxxxx_feb2019 filename fname pipe 'dir C:\files\*.sas7bdat /b/s'; data test; infile fname; input filename :&$100.; new_var=substr(filename,prxmatch('/_\d{8}\./', filename)+31,7); output; run; data test2; set test; date1=input(new_var,anydtdte7.); lastDay=intnx ('month',date1,0,'E'); filedate=lastday; format filedate date9.; keep filename filedate; run;
... View more