You want the TRANSLATE function, not TRANWRD.
%let Date_today=%sysfunc(translate(%sysfunc(today(),ddmmyy10.),"_","/"));
%put &=date_today;
Because the three byte string you asked TRANWRD to change did not appear, so it made no changes.
1 %put %sysfunc(tranwrd(%sysfunc(today(),ddmmyy10.),"/","_")); 16/11/2025
You could remove the quote characters from the strings.
2 %put %sysfunc(tranwrd(%sysfunc(today(),ddmmyy10.),/,_)); 16_11_2025
You could switch to using TRANSLATE, which replaces individual bytes. Remember that the order of the TO and FROM arguments is reversed.
3 %put %sysfunc(translate(%sysfunc(today(),ddmmyy10.),_,/)); 16_11_2025
Note if you include multiple bytes in the FROM and TO arguments then the bytes are paired up by their position in the TO and FROM arguments. As long as you use the same quotes in both TO and FROM (or the source strings does not have any quotes to translate) then you can get away with adding quotes around the characters you want translated.
4 %put %sysfunc(translate(%sysfunc(today(),ddmmyy10.),"_","/")); 16_11_2025
Which could be useful when the values contain commas or other special characters since then you can avoid having to use macro quoting.
5 %put %sysfunc(translate(%sysfunc(today(),ddmmyy10.),",","/")); 16,11,2025
And finally if you plan to use this underscore delimited string in file names the you should use YMD order instead so that the names will sort properly.
6 %put %sysfunc(translate(%sysfunc(today(),yymmdd10.),_,-)); 2025_11_16
And as an added bonus you avoid people confusing October twelfth for the tenth of December.
sasinnovate.png
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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ドル!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.