<?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: How to create a merge macro? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-merge-macro/m-p/796924#M255785</link>
    <description>&lt;P&gt;You didn't end the SET statement with a semi-colon (which was earlier in this thread specifically pointed out by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro merge;
data underly_1617;
    set
        %do i = 1 %to 6;
            &amp;amp;&amp;amp;X&amp;amp;i..1617_
        %end;
    ;    /* This semi-colon ends the SET statement */
run;	
%mend;
%merge&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Use of proper indenting in your code (as I have done) helps find these types of problems. Don't write code without proper indenting.&lt;/P&gt;</description>
    <pubDate>Thu, 17 Feb 2022 17:02:59 GMT</pubDate>
    <dc:creator>PaigeMiller</dc:creator>
    <dc:date>2022-02-17T17:02:59Z</dc:date>
    <item>
      <title>How to create a merge macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-merge-macro/m-p/796893#M255766</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to create a macro to merge the sample data sets as I show below.&amp;nbsp; &amp;nbsp;There are a total of ten of them, I don't list all the them.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data ARIunderly_1617;
	set hou1617_ kc1617_ pit1617_ ;
run;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;My macro code is shown below.&amp;nbsp; I know the code is not right, any idea how to fix it?&amp;nbsp; Thanks.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let X1=VAN;
%let X2=ROC;
%let X3=SEA; 

%macro aaa;

%do i  = 1 %to 3;
data underly_1617;
	set &amp;amp;&amp;amp;X&amp;amp;i..1617_;
run;

%end; 
%mend;
%aaa;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Feb 2022 14:59:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-merge-macro/m-p/796893#M255766</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2022-02-17T14:59:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a merge macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-merge-macro/m-p/796897#M255768</link>
      <description>&lt;P&gt;Your non-macro code shows one DATA step with one SET statement with three datasets, not three separate DATA steps with a SET statement each, so you need to make your macro create such a statement.&lt;/P&gt;
&lt;P&gt;Instead of&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%do i  = 1 %to 3;
data underly_1617;
	set &amp;amp;&amp;amp;X&amp;amp;i..1617_;
run;
%end; 
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;you need&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data underly_1617;
set
%do i  = 1 %to 3;
  &amp;amp;&amp;amp;X&amp;amp;i..1617_
%end;
; /* this ends the SET */
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 17 Feb 2022 15:15:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-merge-macro/m-p/796897#M255768</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-02-17T15:15:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a merge macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-merge-macro/m-p/796898#M255769</link>
      <description>&lt;P&gt;BTW your subject line is wrong, this is not a MERGE, it's a SET, or also called "stacking".&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 15:16:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-merge-macro/m-p/796898#M255769</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-02-17T15:16:38Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a merge macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-merge-macro/m-p/796920#M255783</link>
      <description>&lt;P&gt;I got an error message.&amp;nbsp; Where did I do wrong?&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro merge;
data underly_1617;
	set
	%do i  = 1 %to 6;
	  &amp;amp;&amp;amp;X&amp;amp;i..1617_
	%end;
run;	
%mend;
%merge;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;MPRINT(MERGE): data underly_1617;&lt;BR /&gt;MLOGIC(MERGE): %DO loop beginning; index variable I; start value is 1; stop value is 6; by value is&lt;BR /&gt;1.&lt;BR /&gt;SYMBOLGEN: &amp;amp;&amp;amp; resolves to &amp;amp;.&lt;BR /&gt;SYMBOLGEN: Macro variable I resolves to 1&lt;BR /&gt;SYMBOLGEN: Macro variable X1 resolves to VAN&lt;BR /&gt;MLOGIC(MERGE): %DO loop index variable I is now 2; loop will iterate again.&lt;BR /&gt;SYMBOLGEN: &amp;amp;&amp;amp; resolves to &amp;amp;.&lt;BR /&gt;SYMBOLGEN: Macro variable I resolves to 2&lt;BR /&gt;SYMBOLGEN: Macro variable X2 resolves to ROC&lt;BR /&gt;MLOGIC(MERGE): %DO loop index variable I is now 3; loop will iterate again.&lt;BR /&gt;SYMBOLGEN: &amp;amp;&amp;amp; resolves to &amp;amp;.&lt;BR /&gt;SYMBOLGEN: Macro variable I resolves to 3&lt;BR /&gt;SYMBOLGEN: Macro variable X3 resolves to SEA&lt;BR /&gt;MLOGIC(MERGE): %DO loop index variable I is now 4; loop will iterate again.&lt;BR /&gt;SYMBOLGEN: &amp;amp;&amp;amp; resolves to &amp;amp;.&lt;BR /&gt;SYMBOLGEN: Macro variable I resolves to 4&lt;BR /&gt;SYMBOLGEN: Macro variable X4 resolves to HOU&lt;BR /&gt;MLOGIC(MERGE): %DO loop index variable I is now 5; loop will iterate again.&lt;BR /&gt;SYMBOLGEN: &amp;amp;&amp;amp; resolves to &amp;amp;.&lt;BR /&gt;SYMBOLGEN: Macro variable I resolves to 5&lt;BR /&gt;SYMBOLGEN: Macro variable X5 resolves to KC&lt;BR /&gt;MLOGIC(MERGE): %DO loop index variable I is now 6; loop will iterate again.&lt;BR /&gt;SYMBOLGEN: &amp;amp;&amp;amp; resolves to &amp;amp;.&lt;BR /&gt;SYMBOLGEN: Macro variable I resolves to 6&lt;BR /&gt;SYMBOLGEN: Macro variable X6 resolves to PIT&lt;BR /&gt;MLOGIC(MERGE): %DO loop index variable I is now 7; loop will not iterate again.&lt;BR /&gt;MPRINT(MERGE): set VAN1617_ ROC1617_ SEA1617_ HOU1617_ KC1617_ PIT1617_ run;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;ERROR: File WORK.RUN.DATA does not exist.&lt;/FONT&gt;&lt;BR /&gt;MLOGIC(MERGE): Ending execution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 16:45:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-merge-macro/m-p/796920#M255783</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2022-02-17T16:45:02Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a merge macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-merge-macro/m-p/796924#M255785</link>
      <description>&lt;P&gt;You didn't end the SET statement with a semi-colon (which was earlier in this thread specifically pointed out by&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/11562"&gt;@Kurt_Bremser&lt;/a&gt;)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro merge;
data underly_1617;
    set
        %do i = 1 %to 6;
            &amp;amp;&amp;amp;X&amp;amp;i..1617_
        %end;
    ;    /* This semi-colon ends the SET statement */
run;	
%mend;
%merge&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Use of proper indenting in your code (as I have done) helps find these types of problems. Don't write code without proper indenting.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 17:02:59 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-merge-macro/m-p/796924#M255785</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2022-02-17T17:02:59Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a merge macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-merge-macro/m-p/796927#M255786</link>
      <description>&lt;P&gt;Failure to copy/paste.&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 17:17:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-merge-macro/m-p/796927#M255786</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2022-02-17T17:17:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a merge macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-merge-macro/m-p/796928#M255787</link>
      <description>Yes, forgot to add semicolon at the end.</description>
      <pubDate>Thu, 17 Feb 2022 17:22:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-merge-macro/m-p/796928#M255787</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2022-02-17T17:22:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to create a merge macro?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-merge-macro/m-p/796956#M255798</link>
      <description>&lt;P&gt;It is much clearer if you indent the MACRO statements independently from the SAS statements.&lt;/P&gt;
&lt;P&gt;Right now you have this inconsistent indentation:&lt;/P&gt;
&lt;P&gt;For the macro code you are using 8 spaces of indentation.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For the SAS code you are using 4 in some places and 8 in others.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2022-02-17 132051.jpg" style="width: 403px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/68604i243A227EB9C71C39/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2022-02-17 132051.jpg" alt="Screenshot 2022-02-17 132051.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Instead be consistent. Then when you are trying to see how the logic of the macro works it is easier. And you are trying to follow the flow of the SAS code the macro is generating it is also easier.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro merge;
data underly_1617;
    set
    %do i = 1 %to 6;
        &amp;amp;&amp;amp;X&amp;amp;i..1617_
    %end;
    ; 
run;	
%mend;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Feb 2022 18:26:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-create-a-merge-macro/m-p/796956#M255798</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2022-02-17T18:26:45Z</dc:date>
    </item>
  </channel>
</rss>

