<?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 file name via Windows Environment Variable, or SAS Internal Approach in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-file-name-via-Windows-Environment-Variable-or-SAS-Internal/m-p/587798#M167905</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc printto print='output-file'
new;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Perhaps amounts to same problem mentioned initially -- if we could just get that 'output-file' name to be unique.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 11 Sep 2019 11:46:44 GMT</pubDate>
    <dc:creator>NKormanik</dc:creator>
    <dc:date>2019-09-11T11:46:44Z</dc:date>
    <item>
      <title>SAS file name via Windows Environment Variable, or SAS Internal Approach</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-file-name-via-Windows-Environment-Variable-or-SAS-Internal/m-p/587763#M167894</link>
      <description>&lt;P&gt;Wanted to do a number of runs, one per SAS session.&amp;nbsp; Quit SAS.&amp;nbsp; Back in.&amp;nbsp; Run another program, or same program with different parameters.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Wanted a different "print output" file each time.&amp;nbsp; (Not the same as log.&amp;nbsp; And not same as .html)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Accumulate a &lt;STRONG&gt;set&lt;/STRONG&gt; of these print output files, then look them over.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS seems to have no way of directly allowing this.&amp;nbsp; (Yes, for log files...&amp;nbsp; via %v -- but strange, at that.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, SAS documentation says, go ahead and use Windows Environment Variables for or within SAS file names.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hmm.&amp;nbsp; Sounded like a solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%random% is an internal, built-in WEV.&amp;nbsp; Tried it in SAS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;SAS System Option File entry:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-ALTPRINT "c:\0_SAS_1\output_%random%.txt"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;and&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-ALTPRINT "c:\0_SAS_1\output_random.txt"&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Along with other WEV attempts.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Nothing worked.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, again, the idea was to create output files, one after another, per SAS 'session', named uniquely.&amp;nbsp; (Current time would be perfect, by the way, but 'random' would work.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any suggestions greatly appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Nicholas Kormanik&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2019 09:42:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-file-name-via-Windows-Environment-Variable-or-SAS-Internal/m-p/587763#M167894</guid>
      <dc:creator>NKormanik</dc:creator>
      <dc:date>2019-09-11T09:42:26Z</dc:date>
    </item>
    <item>
      <title>Re: SAS file name via Windows Environment Variable, or SAS Internal Approach</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-file-name-via-Windows-Environment-Variable-or-SAS-Internal/m-p/587779#M167901</link>
      <description>&lt;P&gt;If you fine withy using an initial PROC PRINTO in your program(s) or autoxec, you can use &amp;amp;SYSDATE and &amp;amp;SYSTIME automatic macro variables. Only problem with this is that &amp;amp;SYSTIME is on minute level, so you can't execute your programs too frequently.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2019 11:10:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-file-name-via-Windows-Environment-Variable-or-SAS-Internal/m-p/587779#M167901</guid>
      <dc:creator>LinusH</dc:creator>
      <dc:date>2019-09-11T11:10:41Z</dc:date>
    </item>
    <item>
      <title>Re: SAS file name via Windows Environment Variable, or SAS Internal Approach</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-file-name-via-Windows-Environment-Variable-or-SAS-Internal/m-p/587780#M167902</link>
      <description>Have you seen the examples of using proc printto?&lt;BR /&gt;&lt;A href="https://documentation.sas.com/?docsetId=proc&amp;amp;docsetVersion=9.4&amp;amp;docsetTarget=n1oardywxmmut7n1pol0zkj5u1ok.htm&amp;amp;locale=en" target="_blank"&gt;https://documentation.sas.com/?docsetId=proc&amp;amp;docsetVersion=9.4&amp;amp;docsetTarget=n1oardywxmmut7n1pol0zkj5u1ok.htm&amp;amp;locale=en&lt;/A&gt;&lt;BR /&gt;You have complete control of the filename here so you could use one with a datetime to be sure the names are unique.</description>
      <pubDate>Wed, 11 Sep 2019 11:11:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-file-name-via-Windows-Environment-Variable-or-SAS-Internal/m-p/587780#M167902</guid>
      <dc:creator>JosvanderVelden</dc:creator>
      <dc:date>2019-09-11T11:11:44Z</dc:date>
    </item>
    <item>
      <title>Re: SAS file name via Windows Environment Variable, or SAS Internal Approach</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-file-name-via-Windows-Environment-Variable-or-SAS-Internal/m-p/587798#M167905</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc printto print='output-file'
new;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Perhaps amounts to same problem mentioned initially -- if we could just get that 'output-file' name to be unique.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2019 11:46:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-file-name-via-Windows-Environment-Variable-or-SAS-Internal/m-p/587798#M167905</guid>
      <dc:creator>NKormanik</dc:creator>
      <dc:date>2019-09-11T11:46:44Z</dc:date>
    </item>
    <item>
      <title>Re: SAS file name via Windows Environment Variable, or SAS Internal Approach</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-file-name-via-Windows-Environment-Variable-or-SAS-Internal/m-p/587894#M167937</link>
      <description>&lt;P&gt;I am not sure that you need to stop and restart SAS to accomplish what you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if you want something that does this "automagically" perhaps placing information that could be used as a filename in a control data set and then using call execute to execute each program variation with a Proc Printto preceding the actual "program" executed. Or an ODS destination sandwich around the programs to direct output to a separate file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you mention "different parameters" another question becomes how are you using "different parameters"?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13674"&gt;@LinusH&lt;/a&gt;'s suggestion of &amp;amp;Sysdate and &amp;amp;Systime could be extended by having a code snippet that generates a&amp;nbsp;10 random digit macro variable and append that to the date and time construct in the file name. Not a 100% guarantee of no duplicate but the likelihood is vanishingly small.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Sep 2019 15:00:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-file-name-via-Windows-Environment-Variable-or-SAS-Internal/m-p/587894#M167937</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-09-11T15:00:39Z</dc:date>
    </item>
    <item>
      <title>Re: SAS file name via Windows Environment Variable, or SAS Internal Approach</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-file-name-via-Windows-Environment-Variable-or-SAS-Internal/m-p/588068#M168015</link>
      <description>&lt;P&gt;Me thinks we're getting close....&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;"a code snippet that generates a&amp;nbsp;10 random digit macro variable"&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And then use that code snippet in the SAS file name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class=" language-sas"&gt;&lt;CODE class="  language-sas"&gt;&lt;SPAN class="token procnames"&gt;proc&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;printto&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;print&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'output-code-snippet'&lt;/SPAN&gt;
new&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next step is?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2019 00:41:56 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-file-name-via-Windows-Environment-Variable-or-SAS-Internal/m-p/588068#M168015</guid>
      <dc:creator>NKormanik</dc:creator>
      <dc:date>2019-09-12T00:41:56Z</dc:date>
    </item>
    <item>
      <title>Re: SAS file name via Windows Environment Variable, or SAS Internal Approach</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-file-name-via-Windows-Environment-Variable-or-SAS-Internal/m-p/588388#M168144</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/22691"&gt;@NKormanik&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Me thinks we're getting close....&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;&lt;SPAN&gt;"a code snippet that generates a&amp;nbsp;10 random digit macro variable"&lt;/SPAN&gt;&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And then use that code snippet in the SAS file name.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;&lt;SPAN class="token procnames"&gt;proc&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;printto&lt;/SPAN&gt; &lt;SPAN class="token procnames"&gt;print&lt;/SPAN&gt;&lt;SPAN class="token operator"&gt;=&lt;/SPAN&gt;&lt;SPAN class="token string"&gt;'output-code-snippet'&lt;/SPAN&gt;
new&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;
&lt;SPAN class="token procnames"&gt;run&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;;&lt;/SPAN&gt;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Next step is?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I might try something like:&lt;/P&gt;
&lt;PRE&gt;data _null_;
 call symputx('d',put(today(),yymmddn8.));
 x= int(rand('uniform')*10000000000);
 call symputx('rd',x);
 call symputx('t',cats(put(hour(time()),z2.),put(minute(time()),z2.)));
run;

proc printto print="c:\folder\subfolder\basename_&amp;amp;d._&amp;amp;t._&amp;amp;rd..txt" new; 
run;&lt;/PRE&gt;
&lt;P&gt;put the data step in a macro and call it&amp;nbsp;before each proc printo. the Time component may not be much actual help in your need except for sort bits.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or for extra added difficulty in getting all the functions aligned:&lt;/P&gt;
&lt;PRE&gt;%macro myfname(base=);
%let rd= %sysfunc( int(%sysfunc(rand(uniform))*10000000000) );
%let d = %sysfunc(putn(%sysfunc(today()),yymmddn8.));
%let t = %sysfunc(cats(%sysfunc(putn(%sysfunc(hour(%sysfunc(time()))),z2.)),%sysfunc(putn(%sysfunc(minute(%sysfunc(time()))),z2.))));
&amp;amp;base._&amp;amp;d._&amp;amp;t._&amp;amp;rd
%mend;

proc printto print="%myfname(base=c:\folder\).txt" new; run;
proc print data=sashelp.class;
run;
proc printto;run;&lt;/PRE&gt;
&lt;P&gt;You could provide a path, make sure to have the closing slash as a default in&amp;nbsp;the macro definition by providing the&amp;nbsp;path as a default value for base:&lt;/P&gt;
&lt;PRE&gt;%macro myfname(base=c:\folder\subfolder\);&lt;/PRE&gt;
&lt;P&gt;Which would make the call to proc printo look like:&lt;/P&gt;
&lt;PRE&gt;proc printto print="%myfname.txt" new;&lt;/PRE&gt;
&lt;P&gt;Note that the double quotes around the macro call are required. Single quotes won't resolve. I left the option of the file extension, the .txt in the call because you may want to use Proc Printo log= at some point and wouldn't actually want to have the same extension accidentally. If you have enough discipline that would never happen you could make the extension part of the macro value by using&lt;/P&gt;
&lt;PRE&gt;&amp;amp;base._&amp;amp;d._&amp;amp;t._&amp;amp;rd..txt&lt;/PRE&gt;
&lt;P&gt;The two dots are needed because the first is used by the macro processor to indicate concatenation and would "eat" the first period and TXT would not be an extension.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2019 21:49:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-file-name-via-Windows-Environment-Variable-or-SAS-Internal/m-p/588388#M168144</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-09-12T21:49:20Z</dc:date>
    </item>
  </channel>
</rss>

