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

I need help with the following. Im not a SAS guru. Im in the process of building automated SAS runs, the SAS code need to autoupdate the libname with the current month's date (however the day will ALWAYS be the 7th).

 

the libname should look like this this month:

libname mylib 'C:\Users\folder1\Folder2\2017-06-07'

next month:

libname mylib 'C:\Users\folder1\Folder2\2017-07-07'

the month after that

libname mylib 'C:\Users\folder1\Folder2\2017-08-07'

 

I struggle with this , please assist.

1 ACCEPTED SOLUTION

Accepted Solutions
5 REPLIES 5
RW9
Diamond | Level 26 RW9
Diamond | Level 26

This should work:

data _null_;
  call symputx('D',put(intnx('month',today(),0,'b'),yymmdd10.));
run;
libname mylib 'C:\Users\folder1\Folder2\&d.';
Kurt_Bremser
Super User

Just what @RW9 suggested, but with one little caveat:

libname mylib "C:\Users\folder1\Folder2\&d.";

Note the double quotes, single quotes would prevent the resolution of the macro variable.

MadMax
Calcite | Level 5

@Kurt_Bremser @RW9 

Thank you for the quick responses, i still struggle with the hardcoding of the 7th day in the same question.

Kurt_Bremser
Super User

Then you should determine the date like that:

data _null_;
mydate = input(put(today(),yymmn6.) !! '07',yymmdd8.);
call symput('d',put(mydate,yymmddd10.));
run;
MadMax
Calcite | Level 5

@Kurt_Bremser

Much appreciated!

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 1066 views
  • 1 like
  • 3 in conversation