<?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: Building a filename from prompt variable in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Building-a-filename-from-prompt-variable/m-p/461144#M29733</link>
    <description>&lt;P&gt;Since the macro statements are resolved before the data step runs, I like to keep them separate in code, for clarity:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let month = %sysfunc(putn(%sysfunc(month("&amp;amp;PV_ReportMonth."d)), z2.));
%let year = %sysfunc(year("&amp;amp;PV_ReportMonth."d));
%let mytextfilepath = C:\mypath\mytextfile.&amp;amp;month.&amp;amp;day..txt;

Data myDataSet ;
infile "&amp;amp;mytextfilepath" DLM='|' firstobs=2; 
input
  Var1 ~$10. 
  Var2 $ 
  Yada $ 
  Blah $
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In reality, I would create the macro variable in a preceding data step with call symput, as that removes the need for the %sysfunc calls.&lt;/P&gt;</description>
    <pubDate>Wed, 09 May 2018 17:55:03 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2018-05-09T17:55:03Z</dc:date>
    <item>
      <title>Building a filename from prompt variable</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Building-a-filename-from-prompt-variable/m-p/461132#M29732</link>
      <description>&lt;P&gt;I am importing text file and want to build the file path based on the month and year from a prompt variable, then use the file path in&amp;nbsp; an infile statement. Normally strings are my thing but apparently not in SAS. I have included a condensed version of my code to show what I am trying to accomplish. Any advice?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Data myDataSet ;
	%let month = %sysfunc(putn(%sysfunc(month("&amp;amp;PV_ReportMonth."d)), z2.));
	%let year = %sysfunc(year("&amp;amp;PV_ReportMonth."d));

	/* I want to dynamically build the file name and path from a Date Prompt variable &amp;amp;PV_ReportMonth */
	mytextfilepath = "C:\mypath\mytextfile"||@month||@day||".txt";

	/* So if user chose May 2018. mytextfilepath would be "C:\mypath\mytextfile052018.txt"

	/* And use it like this */
	infile mytextfilepath DLM='|' firstobs=2; 
	input Var1 ~$10. 
		Var2 $ 
		Yada $ 
		Blah $;
run;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 May 2018 17:33:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Building-a-filename-from-prompt-variable/m-p/461132#M29732</guid>
      <dc:creator>eg_michael</dc:creator>
      <dc:date>2018-05-09T17:33:14Z</dc:date>
    </item>
    <item>
      <title>Re: Building a filename from prompt variable</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Building-a-filename-from-prompt-variable/m-p/461144#M29733</link>
      <description>&lt;P&gt;Since the macro statements are resolved before the data step runs, I like to keep them separate in code, for clarity:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let month = %sysfunc(putn(%sysfunc(month("&amp;amp;PV_ReportMonth."d)), z2.));
%let year = %sysfunc(year("&amp;amp;PV_ReportMonth."d));
%let mytextfilepath = C:\mypath\mytextfile.&amp;amp;month.&amp;amp;day..txt;

Data myDataSet ;
infile "&amp;amp;mytextfilepath" DLM='|' firstobs=2; 
input
  Var1 ~$10. 
  Var2 $ 
  Yada $ 
  Blah $
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In reality, I would create the macro variable in a preceding data step with call symput, as that removes the need for the %sysfunc calls.&lt;/P&gt;</description>
      <pubDate>Wed, 09 May 2018 17:55:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Building-a-filename-from-prompt-variable/m-p/461144#M29733</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2018-05-09T17:55:03Z</dc:date>
    </item>
    <item>
      <title>Re: Building a filename from prompt variable</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/Building-a-filename-from-prompt-variable/m-p/461156#M29734</link>
      <description>&lt;P&gt;Perfect, Thank you Kurt!&amp;nbsp; - &amp;nbsp;it works perfect &lt;img id="smileyhappy" class="emoticon emoticon-smileyhappy" src="https://communities.sas.com/i/smilies/16x16_smiley-happy.png" alt="Smiley Happy" title="Smiley Happy" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 May 2018 18:37:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/Building-a-filename-from-prompt-variable/m-p/461156#M29734</guid>
      <dc:creator>eg_michael</dc:creator>
      <dc:date>2018-05-09T18:37:34Z</dc:date>
    </item>
  </channel>
</rss>

