<?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 combine 02 sets with proc sql in SAS Studio</title>
    <link>https://communities.sas.com/t5/SAS-Studio/How-to-combine-02-sets-with-proc-sql/m-p/454196#M5237</link>
    <description>&lt;P&gt;Make sure to use UNION ALL otherwise duplicate records are excluded.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 14 Apr 2018 19:17:07 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2018-04-14T19:17:07Z</dc:date>
    <item>
      <title>How to combine 02 sets with proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-combine-02-sets-with-proc-sql/m-p/454138#M5224</link>
      <description>&lt;P&gt;&lt;STRONG&gt;These are 02 data sets below:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;South.dat&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;S 43 3 27&lt;/P&gt;&lt;P&gt;S 44 3 24&lt;/P&gt;&lt;P&gt;S 45 3&amp;nbsp; 2&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;North.dat&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;N 21 5 41 1&lt;/P&gt;&lt;P&gt;N 87 4 33 3&lt;/P&gt;&lt;P&gt;N 65 2 67 1&lt;/P&gt;&lt;P&gt;N 66 2&amp;nbsp; 7 &amp;nbsp;1&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA southentrance;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; INFILE '/folders/myfolders/sas littlebook/South.dat';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;INPUT Entrance $ PassNumber PartySize Age;&lt;/P&gt;&lt;P&gt;PROC PRINT DATA = southentrance;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; TITLE 'South Entrance Data';&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA northentrance;&lt;/P&gt;&lt;P&gt;&amp;nbsp;INFILE '/folders/myfolders/sas littlebook/North.dat';&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; INPUT Entrance $ PassNumber PartySize Age Lot;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; PROC PRINT DATA = northentrance;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; TITLE 'North Entrance Data';&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/* Create a data set, both, combining northentrance and southentrance*/&lt;/P&gt;&lt;P&gt;/* Create a variable, AmountPaid, based on value of variable Age*/&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATA both;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; SET southentrance northentrance;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; IF Age = . THEN AmountPaid = .;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ELSE IF Age &amp;lt; 3&amp;nbsp; THEN AmountPaid = 0;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ELSE IF Age &amp;lt; 65 THEN AmountPaid = 35;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ELSE AmountPaid = 27;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;PROC PRINT DATA = both;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; TITLE 'Both Entrances';&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How do I write this program with Proc sql to combine these 02 sets together:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;TK&lt;/P&gt;</description>
      <pubDate>Sat, 14 Apr 2018 11:00:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-combine-02-sets-with-proc-sql/m-p/454138#M5224</guid>
      <dc:creator>bondtk</dc:creator>
      <dc:date>2018-04-14T11:00:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine 02 sets with proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-combine-02-sets-with-proc-sql/m-p/454143#M5225</link>
      <description>&lt;P&gt;Your are joining the tables vertically, so&amp;nbsp;you can use set operators in PROC SQL (OUTER UNION, UNION, EXCEPT, INTERSECT). For your requirement OUTER UNION with corresponding keyword with CASE expression can give you the result.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
Create table want as 
select *,CASE WHEN AGE=. THEN  .
			  WHEN Age &amp;lt; 3  THEN 0
			  WHEN Age &amp;lt; 65 THEN 35
			  ELSE 27 END AS AmountPaid
	FROM southentrance
OUTER UNION CORR
select *,CASE WHEN AGE=. THEN  .
			  WHEN Age &amp;lt; 3  THEN 0
			  WHEN Age &amp;lt; 65 THEN 35
			  ELSE 27 END AS AmountPaid
	FROM northentrance
;
QUIT;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 14 Apr 2018 13:35:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-combine-02-sets-with-proc-sql/m-p/454143#M5225</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-04-14T13:35:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine 02 sets with proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-combine-02-sets-with-proc-sql/m-p/454144#M5226</link>
      <description>&lt;P&gt;Please try the proc sql with union&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have1;
input Entrance $ PassNumber PartySize Age;
cards;
S 43 3 27
S 44 3 24
S 45 3  2
;

data have2;
input Entrance $ PassNumber PartySize Age;
cards;
N 21 5 41 1
N 87 4 33 3
N 65 2 67 1
N 66 2  7  1
;


proc sql;
create table want as select *, case when age &amp;lt; 3 then 0 when age &amp;lt; 65 then 35 when age  eq . then . else 27 end as 
amountpaid from (select * from have1 
union 
select * from have2);
quit;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 14 Apr 2018 13:39:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-combine-02-sets-with-proc-sql/m-p/454144#M5226</guid>
      <dc:creator>Jagadishkatam</dc:creator>
      <dc:date>2018-04-14T13:39:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine 02 sets with proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-combine-02-sets-with-proc-sql/m-p/454196#M5237</link>
      <description>&lt;P&gt;Make sure to use UNION ALL otherwise duplicate records are excluded.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 14 Apr 2018 19:17:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-combine-02-sets-with-proc-sql/m-p/454196#M5237</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-04-14T19:17:07Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine 02 sets with proc sql</title>
      <link>https://communities.sas.com/t5/SAS-Studio/How-to-combine-02-sets-with-proc-sql/m-p/454387#M5261</link>
      <description>&lt;P&gt;thanks Jag&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it worked, I tried it with union all....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;TK&lt;/P&gt;</description>
      <pubDate>Mon, 16 Apr 2018 10:24:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Studio/How-to-combine-02-sets-with-proc-sql/m-p/454387#M5261</guid>
      <dc:creator>bondtk</dc:creator>
      <dc:date>2018-04-16T10:24:37Z</dc:date>
    </item>
  </channel>
</rss>

