The company I work for has a system that pulls in prices overnight and places them in a particular library. I've been working on automating regressions based on this data, but need to automate which date the regression pulls in order to make it work without daily updating. My beginning data step is below.
data work.regression;
set prod_stg.prices_transpose_22sep2014;
The files will always be found in the prod_stg library and the data will always begin with prices_transpose_ followed by most recent date in date9 format. For example, data for today would be in prod_stg.prices_transpose_15oct2014. Does anyone know how to automate the date at the end of the data file to pull back the most recent data set? It also would need to be able to go back more than one day if data was missing (weekends, holidays, ect.)
Thanks!
%let lastdat=;
proc sql noprint;
select memname into :lastdat from dictionary.tables where
upcase(libname) = 'PROD_STG' and upcase(memname) like 'PRICES_TRANSPOSE_%'
order by input(scan(memname,-1,'_'),date.) desc;
quit;
data work.regression;
set prod_stg.&lastdat;
run;
%let lastdat=;
proc sql noprint;
select memname into :lastdat from dictionary.tables where
upcase(libname) = 'PROD_STG' and upcase(memname) like 'PRICES_TRANSPOSE_%'
order by input(scan(memname,-1,'_'),date.) desc;
quit;
data work.regression;
set prod_stg.&lastdat;
run;
Hello,
If the data is created on working days :
%let rundate=%sysfunc(intnx(WEEKDAY,%sysfunc(today()),-1),date9.);
%put &rundate;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.