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

Using the macro below, &sysdate appears in the format DATEw. (10OCT12).

%let foldername= &sysdate.;

How do I make it appear in the format YYMON. (2012-OCT) instead, inside the macro statement (which is used in the precode of a DI Studio job)?

Thanks for your time. Smiley Happy

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

YYMON. returns in my environemt 2012OCT without a dash. But that's for a foldername may be even better.

%let foldername=%sysfunc(inputn(&sysdate,date9.),yymon.);

View solution in original post

4 REPLIES 4
Patrick
Opal | Level 21

YYMON. returns in my environemt 2012OCT without a dash. But that's for a foldername may be even better.

%let foldername=%sysfunc(inputn(&sysdate,date9.),yymon.);

data_null__
Jade | Level 19

It might be better to use TODAY() function.

%let foldername=%sysfunc(today(),yymon.);
%put &foldername;
Patrick
Opal | Level 21

Why? Are you having these week-long EG sessions in mind or do you have another reason for this statement?

Patrick
Opal | Level 21

@Einar

Based on what I assume data_null had in mind the following for you to consider:

You are developing DI jobs which normally are run overnight in batch. What happens if your job runs over midnight at a month end. Which foldername should the job generate?

If you are using &sysdate then the date will be used when the job started, today() will give you the date when you call it in the job. Still: both might be wrong. There could be some downtime and your job starts after midnight - or even a day later because the server was really down and you need to run catch-up runs.

One way to avoid all these problems is to base all such date based name generation not on the calendar date but on the date of your data and you normally know from which date your data is.

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 connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 1150 views
  • 0 likes
  • 3 in conversation