<?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: proc sql &amp;quot;union&amp;quot;:Way of clarify original dataset in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-quot-union-quot-Way-of-clarify-original-dataset/m-p/299195#M60419</link>
    <description>&lt;P&gt;If you insist on using SQL UNION. Please note that unless you specify UNION CORRESPONDING, variables from both tables are matched simply on their position in the variable list. In your example, B is matched with C.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suggest to try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
   create table Dataset3 as
   select "Dataset1" as source, A, B from Dataset1
      union corr
   select "Dataset2" as source, A, C as B from Dataset2;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Mon, 19 Sep 2016 03:18:42 GMT</pubDate>
    <dc:creator>PGStats</dc:creator>
    <dc:date>2016-09-19T03:18:42Z</dc:date>
    <item>
      <title>proc sql "union":Way of clarify original dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-quot-union-quot-Way-of-clarify-original-dataset/m-p/299191#M60417</link>
      <description>&lt;P&gt;Hi,all.&lt;/P&gt;&lt;P&gt;Is there any way of making a variable for catch "original dataset" after union statement when proc sql.&lt;BR /&gt;Though value which exisit both dataset is replaced to final dataset.&lt;BR /&gt;("value which exisit both dataset" is "paper2 b1" in the below example.)&lt;/P&gt;&lt;P&gt;For example&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data Dataset1;
input A$ B$ ;
cards;
paper1 a1
paper2 b1
paper2 b1
;
run;

data Dataset2;
input A$ C$;
cards;
paper2 b1
paper3 c1
;
run;

proc sql;
   create table Dataset3 as
   select * from Dataset1
      union
   select * from Dataset2;
quit;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Image of "Dataset3"&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/4946i1E2A988F91C04303/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="after_union.JPG" title="after_union.JPG" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to get the result like below,in short,variable "XX" have the value of the observation's mother or parent dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any value is ok(character or number) if we can grasp the diffenrence of parent dataset.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Image of my hoping.&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/4947iAFA3F72968F67006/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="after_union_XX1.JPG" title="after_union_XX1.JPG" /&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/4948i428FB9176CC58DE3/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="after_union_XX2.JPG" title="after_union_XX2.JPG" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Sep 2016 01:32:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-quot-union-quot-Way-of-clarify-original-dataset/m-p/299191#M60417</guid>
      <dc:creator>t_ar_taat</dc:creator>
      <dc:date>2016-09-19T01:32:10Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql "union":Way of clarify original dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-quot-union-quot-Way-of-clarify-original-dataset/m-p/299194#M60418</link>
      <description>&lt;P&gt;Use a data step?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
Set a b indsname=source;
Dset=source;
Run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Sep 2016 02:46:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-quot-union-quot-Way-of-clarify-original-dataset/m-p/299194#M60418</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-09-19T02:46:57Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql "union":Way of clarify original dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-quot-union-quot-Way-of-clarify-original-dataset/m-p/299195#M60419</link>
      <description>&lt;P&gt;If you insist on using SQL UNION. Please note that unless you specify UNION CORRESPONDING, variables from both tables are matched simply on their position in the variable list. In your example, B is matched with C.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I suggest to try:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
   create table Dataset3 as
   select "Dataset1" as source, A, B from Dataset1
      union corr
   select "Dataset2" as source, A, C as B from Dataset2;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Sep 2016 03:18:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-quot-union-quot-Way-of-clarify-original-dataset/m-p/299195#M60419</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2016-09-19T03:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql "union":Way of clarify original dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-quot-union-quot-Way-of-clarify-original-dataset/m-p/299738#M60475</link>
      <description>&lt;P&gt;Hi,Reeza&lt;/P&gt;&lt;P&gt;Thank you for your helping.&lt;/P&gt;&lt;P&gt;Actually I insist on using proc sql,but your information is useful.&lt;/P&gt;&lt;P&gt;Because I never hard "indsname".I'll use it soon.Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 21 Sep 2016 03:52:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-quot-union-quot-Way-of-clarify-original-dataset/m-p/299738#M60475</guid>
      <dc:creator>t_ar_taat</dc:creator>
      <dc:date>2016-09-21T03:52:49Z</dc:date>
    </item>
    <item>
      <title>Re: proc sql "union":Way of clarify original dataset</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/proc-sql-quot-union-quot-Way-of-clarify-original-dataset/m-p/299739#M60476</link>
      <description>Hi,PGStats&lt;BR /&gt;Great! This is what I want.&lt;BR /&gt;Have a nice day,t_ar_taat</description>
      <pubDate>Wed, 21 Sep 2016 03:55:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/proc-sql-quot-union-quot-Way-of-clarify-original-dataset/m-p/299739#M60476</guid>
      <dc:creator>t_ar_taat</dc:creator>
      <dc:date>2016-09-21T03:55:33Z</dc:date>
    </item>
  </channel>
</rss>

