BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
dangoebel
Calcite | Level 5

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!

1 ACCEPTED SOLUTION

Accepted Solutions
Vladislaff
SAS Employee

%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;

View solution in original post

2 REPLIES 2
Vladislaff
SAS Employee

%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;

Loko
Barite | Level 11

Hello,

If the data is created on working days :

%let rundate=%sysfunc(intnx(WEEKDAY,%sysfunc(today()),-1),date9.);

%put &rundate;

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 943 views
  • 0 likes
  • 3 in conversation