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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—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
  • 1526 views
  • 0 likes
  • 3 in conversation