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.
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.);
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.);
It might be better to use TODAY() function.
Why? Are you having these week-long EG sessions in mind or do you have another reason for this statement?
@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 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.