<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Formatting a macro variable in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Formatting-a-macro-variable/m-p/978910#M378700</link>
    <description>&lt;P&gt;You want the TRANSLATE function, not TRANWRD.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let Date_today=%sysfunc(translate(%sysfunc(today(),ddmmyy10.),"_","/"));
%put &amp;amp;=date_today;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 16 Nov 2025 13:30:07 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2025-11-16T13:30:07Z</dc:date>
    <item>
      <title>Formatting a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-a-macro-variable/m-p/978908#M378699</link>
      <description>&lt;P&gt;Hello Experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to display the today date as DD_MM_YY. I apply this code :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let Date_today=%sysfunc(tranwrd(%sysfunc(today(),ddmmyy10.),"/","_"));
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But I have as result DD/MM/YY.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for your help !&lt;/P&gt;</description>
      <pubDate>Sun, 16 Nov 2025 12:47:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-a-macro-variable/m-p/978908#M378699</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2025-11-16T12:47:19Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-a-macro-variable/m-p/978910#M378700</link>
      <description>&lt;P&gt;You want the TRANSLATE function, not TRANWRD.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let Date_today=%sysfunc(translate(%sysfunc(today(),ddmmyy10.),"_","/"));
%put &amp;amp;=date_today;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Nov 2025 13:30:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-a-macro-variable/m-p/978910#M378700</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2025-11-16T13:30:07Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-a-macro-variable/m-p/978911#M378701</link>
      <description>Thank you!</description>
      <pubDate>Sun, 16 Nov 2025 15:55:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-a-macro-variable/m-p/978911#M378701</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2025-11-16T15:55:01Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-a-macro-variable/m-p/978912#M378702</link>
      <description>&lt;P&gt;Because the three byte string you asked TRANWRD to change did not appear, so it made no changes.&lt;/P&gt;
&lt;PRE&gt;1    %put %sysfunc(tranwrd(%sysfunc(today(),ddmmyy10.),"/","_"));
16/11/2025
&lt;/PRE&gt;
&lt;P&gt;You could remove the quote characters from the strings.&lt;/P&gt;
&lt;PRE&gt;2    %put %sysfunc(tranwrd(%sysfunc(today(),ddmmyy10.),/,_));
16_11_2025&lt;/PRE&gt;
&lt;P&gt;You could switch to using TRANSLATE, which replaces individual bytes. Remember that the order of the TO and FROM arguments is reversed.&lt;/P&gt;
&lt;PRE&gt;3    %put %sysfunc(translate(%sysfunc(today(),ddmmyy10.),_,/));
16_11_2025&lt;/PRE&gt;
&lt;P&gt;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.&amp;nbsp; 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.&lt;/P&gt;
&lt;PRE&gt;4    %put %sysfunc(translate(%sysfunc(today(),ddmmyy10.),"_","/"));
16_11_2025&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Which could be useful when the values contain commas or other special characters since then you can avoid having to use macro quoting.&lt;/P&gt;
&lt;PRE&gt;5    %put %sysfunc(translate(%sysfunc(today(),ddmmyy10.),",","/"));
16,11,2025
&lt;/PRE&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;PRE&gt;6    %put %sysfunc(translate(%sysfunc(today(),yymmdd10.),_,-));
2025_11_16
&lt;/PRE&gt;
&lt;P&gt;And as an added bonus you avoid people confusing October twelfth for the tenth of December.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Nov 2025 00:49:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-a-macro-variable/m-p/978912#M378702</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-11-17T00:49:41Z</dc:date>
    </item>
    <item>
      <title>Re: Formatting a macro variable</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Formatting-a-macro-variable/m-p/978913#M378703</link>
      <description>Thank you, Tom !</description>
      <pubDate>Sun, 16 Nov 2025 18:05:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Formatting-a-macro-variable/m-p/978913#M378703</guid>
      <dc:creator>SASdevAnneMarie</dc:creator>
      <dc:date>2025-11-16T18:05:09Z</dc:date>
    </item>
  </channel>
</rss>

