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

Hi I am making an automatic mail everyday where the file i attached included following in the name: 2021_05_06_thursday

The date changes every day so tomorrow it will be 2021_05_07_friday

How can I make a macro that can generate this 

1 ACCEPTED SOLUTION

Accepted Solutions
Sajid01
Meteorite | Level 14

Hello
The following macro generates the date as you have desired

%sysfunc(translate(%sysfunc(date(),yymmdd10.)_%sysfunc(trim(%sysfunc(date(),downame10.))),'_','-'));

For today's date it will give this output :2021_05_06_Thursday as can be seen in the log below


 
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         %put %sysfunc(translate(%sysfunc(date(),yymmdd10.)_%sysfunc(trim(%sysfunc(date(),downame10.))),'_','-'));
 2021_05_06_Thursday
 74         
 75         
 76         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;

 

View solution in original post

5 REPLIES 5
Sajid01
Meteorite | Level 14

Hello
The following macro generates the date as you have desired

%sysfunc(translate(%sysfunc(date(),yymmdd10.)_%sysfunc(trim(%sysfunc(date(),downame10.))),'_','-'));

For today's date it will give this output :2021_05_06_Thursday as can be seen in the log below


 
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         %put %sysfunc(translate(%sysfunc(date(),yymmdd10.)_%sysfunc(trim(%sysfunc(date(),downame10.))),'_','-'));
 2021_05_06_Thursday
 74         
 75         
 76         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;

 

mmea
Quartz | Level 8

Can I make the name of the days in the week (etc. Thursday) to another language?

Sajid01
Meteorite | Level 14

1.Can I make the name of the days in the week (etc. Thursday) to another language?

 I suggest you contact SAS Tech Support.

2.I think your original question is resolved, please mark it solved.

Kurt_Bremser
Super User

@mmea wrote:

Can I make the name of the days in the week (etc. Thursday) to another language?


Use the NLDATEWNw. format:

 

%put %sysfunc(date(),NLDATEWN20.);

It will display the weekday according to your locale.

 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 837 views
  • 0 likes
  • 3 in conversation