<?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 macro parameter with concatenate names in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/macro-parameter-with-concatenate-names/m-p/357339#M274261</link>
    <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;I have mutitlple SAS data sets with names file91 to file14. The last two digits represents years (e.g.91 represents 1991 and 00 represents 2000). I tried to run a macro to generate some results by reading these names. However, I failed to concanate file names within the macro. Could you one help? Thanks.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro getall;

	%do i=91 %to 99;  /*year 1991 to 1999*/
	%getpart1(file&amp;amp;i);
	%end;

	%do i=0 %to 14;  /*year 2000 to 2014*/
	%getpart2(%sysfunc(cats('file',put(&amp;amp;i,z2.))));
	%end;

%mend getall;&lt;BR /&gt;%getall&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 09 May 2017 23:46:16 GMT</pubDate>
    <dc:creator>chenyiwen1717</dc:creator>
    <dc:date>2017-05-09T23:46:16Z</dc:date>
    <item>
      <title>macro parameter with concatenate names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-parameter-with-concatenate-names/m-p/357339#M274261</link>
      <description>&lt;P&gt;Hi All,&lt;/P&gt;
&lt;P&gt;I have mutitlple SAS data sets with names file91 to file14. The last two digits represents years (e.g.91 represents 1991 and 00 represents 2000). I tried to run a macro to generate some results by reading these names. However, I failed to concanate file names within the macro. Could you one help? Thanks.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro getall;

	%do i=91 %to 99;  /*year 1991 to 1999*/
	%getpart1(file&amp;amp;i);
	%end;

	%do i=0 %to 14;  /*year 2000 to 2014*/
	%getpart2(%sysfunc(cats('file',put(&amp;amp;i,z2.))));
	%end;

%mend getall;&lt;BR /&gt;%getall&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 May 2017 23:46:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-parameter-with-concatenate-names/m-p/357339#M274261</guid>
      <dc:creator>chenyiwen1717</dc:creator>
      <dc:date>2017-05-09T23:46:16Z</dc:date>
    </item>
    <item>
      <title>Re: macro parameter with concatenate names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-parameter-with-concatenate-names/m-p/357341#M274262</link>
      <description>&lt;P&gt;Assuming that somewhere you have properly defined %GETPART1 and %GETPART2, your top loop should be fine &amp;nbsp;(Of course I'm not yet convinced that you have defined those other macros, but you'll be able to comment about that easily enough.)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The bottom loop requires a few changes, though. &amp;nbsp;CATS is not needed to concatenate strings in macro language, nor are quotes needed to define a character string. &amp;nbsp;And %SYSFUNC cannot be applied to PUT (only to PUTN or PUTC). &amp;nbsp;So you would need:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;%do i=0 %to 14;&lt;/P&gt;
&lt;P&gt;%getpart2 (file%sysfunc(putn(&amp;amp;i, z2)))&lt;/P&gt;
&lt;P&gt;%end;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 May 2017 23:57:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-parameter-with-concatenate-names/m-p/357341#M274262</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2017-05-09T23:57:09Z</dc:date>
    </item>
    <item>
      <title>Re: macro parameter with concatenate names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-parameter-with-concatenate-names/m-p/357353#M274263</link>
      <description>&lt;P&gt;You can also use a single loop:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro getall;
    %do year=1991 %to 2014;
        %put file%substr(&amp;amp;year, 3, 2);
    %end;
%mend getall;

%getall;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 10 May 2017 01:15:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-parameter-with-concatenate-names/m-p/357353#M274263</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-05-10T01:15:24Z</dc:date>
    </item>
    <item>
      <title>Re: macro parameter with concatenate names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-parameter-with-concatenate-names/m-p/357402#M274264</link>
      <description>&lt;P&gt;Firstly, I would always suggest to combine all "like" data together in one dataset - with a date column for the year if need be. &amp;nbsp;This will considerably shrink your programming effort and make your life much easier.&lt;/P&gt;
&lt;P&gt;You can of course loop by using:&lt;/P&gt;
&lt;PRE&gt;data _null_;
  set sashelp.vtable (where=(libname="WORK" and substr(memname,1,4)="FILE"));
  /* This bit gets generated for each filexx dataset */
  call execute('%getpart1 ('||strip(memname)||');');
  call execute('%getpart2 ('||strip(memname)||');');
run;
&lt;/PRE&gt;
&lt;P&gt;You don't need any hardcoding or loops then of the files, as anything in work with the prefix file will be processed.&lt;/P&gt;
&lt;P&gt;I would still recommend combining them though.&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2017 09:07:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-parameter-with-concatenate-names/m-p/357402#M274264</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-05-10T09:07:10Z</dc:date>
    </item>
    <item>
      <title>Re: macro parameter with concatenate names</title>
      <link>https://communities.sas.com/t5/SAS-Programming/macro-parameter-with-concatenate-names/m-p/357566#M274265</link>
      <description>&lt;P&gt;Thanks Astounding. This is exactly what I want! I shouldn't put the&amp;nbsp;concatenate function or quotes to concatenate string in macro! This sloved my question!&lt;img id="smileywink" class="emoticon emoticon-smileywink" src="https://communities.sas.com/i/smilies/16x16_smiley-wink.png" alt="Smiley Wink" title="Smiley Wink" /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 10 May 2017 16:49:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/macro-parameter-with-concatenate-names/m-p/357566#M274265</guid>
      <dc:creator>chenyiwen1717</dc:creator>
      <dc:date>2017-05-10T16:49:44Z</dc:date>
    </item>
  </channel>
</rss>

