<?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 OUTER UNION CORR by Using Do Loop in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/SAS-OUTER-UNION-CORR-by-Using-Do-Loop/m-p/738413#M230346</link>
    <description>&lt;P&gt;Your %END is in the wrong place.&lt;/P&gt;</description>
    <pubDate>Sun, 02 May 2021 16:20:09 GMT</pubDate>
    <dc:creator>Tom</dc:creator>
    <dc:date>2021-05-02T16:20:09Z</dc:date>
    <item>
      <title>SAS OUTER UNION CORR by Using Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-OUTER-UNION-CORR-by-Using-Do-Loop/m-p/738412#M230345</link>
      <description>&lt;P&gt;Hello all,&lt;BR /&gt;I need to find a way to use loop to union my datasets.&lt;BR /&gt;For example, I have three tables with different column names. I want to union them all by using "outer nuion corr".&lt;BR /&gt;The code like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table new as
select * from a1
outer union corr
select * from b1
outer union corr
select * from c1 ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I want to use the loop function to do these unions.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro union_a;
proc sql;
create table new as
select * from a1
%do i = 2 %to 3;
outer union corr select * from a&amp;amp;i
;
quit;

%end;
%mend;
%union_a;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;it gives me an error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NOTE: Line generated by the invoked macro "UNION_A".
5 outer union corr select * from a&amp;amp;i ;
-----
180

ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;How should I do this? Thank you!&lt;/P&gt;&lt;P&gt;JH&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 02 May 2021 16:16:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-OUTER-UNION-CORR-by-Using-Do-Loop/m-p/738412#M230345</guid>
      <dc:creator>jhusoc</dc:creator>
      <dc:date>2021-05-02T16:16:22Z</dc:date>
    </item>
    <item>
      <title>Re: SAS OUTER UNION CORR by Using Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-OUTER-UNION-CORR-by-Using-Do-Loop/m-p/738413#M230346</link>
      <description>&lt;P&gt;Your %END is in the wrong place.&lt;/P&gt;</description>
      <pubDate>Sun, 02 May 2021 16:20:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-OUTER-UNION-CORR-by-Using-Do-Loop/m-p/738413#M230346</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2021-05-02T16:20:09Z</dc:date>
    </item>
    <item>
      <title>Re: SAS OUTER UNION CORR by Using Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-OUTER-UNION-CORR-by-Using-Do-Loop/m-p/738414#M230347</link>
      <description>Oh yes! Thank you!</description>
      <pubDate>Sun, 02 May 2021 16:25:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-OUTER-UNION-CORR-by-Using-Do-Loop/m-p/738414#M230347</guid>
      <dc:creator>jhusoc</dc:creator>
      <dc:date>2021-05-02T16:25:31Z</dc:date>
    </item>
    <item>
      <title>Re: SAS OUTER UNION CORR by Using Do Loop</title>
      <link>https://communities.sas.com/t5/SAS-Programming/SAS-OUTER-UNION-CORR-by-Using-Do-Loop/m-p/738479#M230365</link>
      <description>&lt;P&gt;SET works much easier and better here.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set a1 b1 c1;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/342187"&gt;@jhusoc&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hello all,&lt;BR /&gt;I need to find a way to use loop to union my datasets.&lt;BR /&gt;For example, I have three tables with different column names. I want to union them all by using "outer nuion corr".&lt;BR /&gt;The code like this:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table new as
select * from a1
outer union corr
select * from b1
outer union corr
select * from c1 ;
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I want to use the loop function to do these unions.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro union_a;
proc sql;
create table new as
select * from a1
%do i = 2 %to 3;
outer union corr select * from a&amp;amp;i
;
quit;

%end;
%mend;
%union_a;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;it gives me an error:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;NOTE: Line generated by the invoked macro "UNION_A".
5 outer union corr select * from a&amp;amp;i ;
-----
180

ERROR 180-322: Statement is not valid or it is used out of proper order.&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;How should I do this? Thank you!&lt;/P&gt;
&lt;P&gt;JH&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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 03 May 2021 03:15:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/SAS-OUTER-UNION-CORR-by-Using-Do-Loop/m-p/738479#M230365</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2021-05-03T03:15:28Z</dc:date>
    </item>
  </channel>
</rss>

