<?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: SAS filename of output in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-filename-of-output/m-p/676190#M203852</link>
    <description>&lt;P&gt;Macro timing mistake. The %LET is dealt with while the data step is compiled, not while it executes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use the proper data step function for setting a macro variable:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _NULL_;
	StringA = '/project/XXXXX/out/XX_EXPORT_';
	StringM = put(today(),YYMMYYN6.);
	StringE = '.csv';
	call symputx('pathname',cats(StringA, StringM, StringE));
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But you can do this in one %LET:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let pathname =/project/XXXXX/out/XX_EXPORT_%sysfunc(today(),YYMMYYN6.).csv;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And since the macro variable &amp;amp;pathname does not contain quotes, add them when it is used:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename OUTPUT "&amp;amp;pathname" encoding='utf-8';&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 12 Aug 2020 15:02:36 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-08-12T15:02:36Z</dc:date>
    <item>
      <title>SAS filename of output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-filename-of-output/m-p/676185#M203848</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to add to the filename the date of today. I tried the code below but it does'nt work.&lt;/P&gt;
&lt;P&gt;How can I use my variable pathname in the filename syntax?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data _NULL_;
	StringA = '/project/XXXXX/out/XX_EXPORT_';
	StringM = %sysfunc(today(), YYMMYYN6.);
	StringE = '.csv';
	%LET pathname = cats(StringA, StringM, StringE);
	put pathname;
run;

filename OUTPUT &amp;amp;pathname encoding='utf-8';
proc export data=XXXXXX.XX_NG outfile=OUTPUT dbms=csv;
run;&lt;/PRE&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Sascha&lt;/P&gt;</description>
      <pubDate>Wed, 12 Aug 2020 14:45:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-filename-of-output/m-p/676185#M203848</guid>
      <dc:creator>SaschaD</dc:creator>
      <dc:date>2020-08-12T14:45:47Z</dc:date>
    </item>
    <item>
      <title>Re: SAS filename of output</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-filename-of-output/m-p/676190#M203852</link>
      <description>&lt;P&gt;Macro timing mistake. The %LET is dealt with while the data step is compiled, not while it executes.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use the proper data step function for setting a macro variable:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _NULL_;
	StringA = '/project/XXXXX/out/XX_EXPORT_';
	StringM = put(today(),YYMMYYN6.);
	StringE = '.csv';
	call symputx('pathname',cats(StringA, StringM, StringE));
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But you can do this in one %LET:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let pathname =/project/XXXXX/out/XX_EXPORT_%sysfunc(today(),YYMMYYN6.).csv;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;And since the macro variable &amp;amp;pathname does not contain quotes, add them when it is used:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename OUTPUT "&amp;amp;pathname" encoding='utf-8';&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 12 Aug 2020 15:02:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-filename-of-output/m-p/676190#M203852</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-08-12T15:02:36Z</dc:date>
    </item>
  </channel>
</rss>

