<?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: What type of join? in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/What-type-of-join/m-p/232950#M42473</link>
    <description>Do you need them side by side or stacked? I would think a union all would work if stacked.  &lt;BR /&gt;&lt;BR /&gt;select * from fm01&lt;BR /&gt;union all&lt;BR /&gt;select * from fm02&lt;BR /&gt;&lt;BR /&gt;If side by side you need a joining variable and you'll need to rename all the variables from each dataset since you can't have multiple variable with the same name.</description>
    <pubDate>Tue, 03 Nov 2015 19:28:34 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2015-11-03T19:28:34Z</dc:date>
    <item>
      <title>What type of join?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-type-of-join/m-p/232945#M42469</link>
      <description>&lt;P&gt;I need to join several tables (3 fiscal months...FM01, FM02, FM03) selecting specific variables that are the same in all the tables and combining all the observations within those tables.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt;&lt;/FONT&gt; &lt;STRONG&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;sql&lt;/FONT&gt;&lt;/STRONG&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;create&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;table&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; FM123 &lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;as&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;select&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; patssn, patsex,patrace,patage&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;from&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;&amp;nbsp;FM01, FM01, FM03&amp;nbsp; *** not sure what typle of join or where to type the join statement?!&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;order&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt; &lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;&lt;FONT color="#0000ff" face="Courier New" size="2"&gt;by&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt; patssn;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;FONT color="#000080" face="Courier New" size="2"&gt;&lt;STRONG&gt;quit&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/FONT&gt;&lt;FONT face="Courier New" size="2"&gt;&lt;FONT face="Courier New" size="2"&gt;;&lt;/FONT&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Nov 2015 19:19:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-type-of-join/m-p/232945#M42469</guid>
      <dc:creator>jenim514</dc:creator>
      <dc:date>2015-11-03T19:19:31Z</dc:date>
    </item>
    <item>
      <title>Re: What type of join?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-type-of-join/m-p/232950#M42473</link>
      <description>Do you need them side by side or stacked? I would think a union all would work if stacked.  &lt;BR /&gt;&lt;BR /&gt;select * from fm01&lt;BR /&gt;union all&lt;BR /&gt;select * from fm02&lt;BR /&gt;&lt;BR /&gt;If side by side you need a joining variable and you'll need to rename all the variables from each dataset since you can't have multiple variable with the same name.</description>
      <pubDate>Tue, 03 Nov 2015 19:28:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-type-of-join/m-p/232950#M42473</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-11-03T19:28:34Z</dc:date>
    </item>
    <item>
      <title>Re: What type of join?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-type-of-join/m-p/232952#M42475</link>
      <description>&lt;P&gt;That &amp;nbsp;worked!&amp;nbsp; Thank you!!&lt;/P&gt;</description>
      <pubDate>Tue, 03 Nov 2015 19:36:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-type-of-join/m-p/232952#M42475</guid>
      <dc:creator>jenim514</dc:creator>
      <dc:date>2015-11-03T19:36:05Z</dc:date>
    </item>
    <item>
      <title>Re: What type of join?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-type-of-join/m-p/232954#M42477</link>
      <description>&lt;P&gt;Union All does work, however Is there a way to join/ merge&amp;nbsp;several tables without having&amp;nbsp;select&amp;nbsp;all the variables from every table I am combining?&amp;nbsp; Say I'm working with 30 variables (out of 150) and I only want to select/ type&amp;nbsp;them once because they are going to be the same variables in every table (stacked observations).&amp;nbsp; Just want to know if there is an easier way to join/ merge the tables.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Nov 2015 20:00:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-type-of-join/m-p/232954#M42477</guid>
      <dc:creator>jenim514</dc:creator>
      <dc:date>2015-11-03T20:00:26Z</dc:date>
    </item>
    <item>
      <title>Re: What type of join?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-type-of-join/m-p/232959#M42482</link>
      <description>&lt;P&gt;First you need to understand that joining (commonly known as merging) and stacking tables are 2 different operations.&lt;/P&gt;
&lt;P&gt;1) If you are joining them (meaning side by side) then as previously mentioned you need to&amp;nbsp;have one or more id variables to join by and you need to rename varibles that have same name in more than one dataset.&lt;/P&gt;
&lt;P&gt;2) If you are stacking them (meaning one after other) then you do not need one or more id variables and you do not need to rename variables that have same name and are of same type.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you do not want to type out variables again and again you can put them in a macro variable eg: %let vartokeep= var1 var2 ...;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;then if you are stacking them together&amp;nbsp;you can use a simple data step:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data want;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;set have1(keep=&amp;amp;vartokeep.) have2(keep=&amp;amp;vartokeep) ...;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Tue, 03 Nov 2015 20:17:39 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-type-of-join/m-p/232959#M42482</guid>
      <dc:creator>ndp</dc:creator>
      <dc:date>2015-11-03T20:17:39Z</dc:date>
    </item>
    <item>
      <title>Re: What type of join?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-type-of-join/m-p/232963#M42485</link>
      <description>&lt;P&gt;I'm with &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/26546"&gt;@ndp﻿&lt;/a&gt; - using a data step is easier in this case. Especially because you can use variable lists in a data step and you can't in proc sql.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data want;
set fm01 fm02 fm03;

/*some examples of keep statements*/
keep var1-var30; /*all variables numbered from var1-var30*/
keep prefix:; /*all variables that start with prefix*/
keep var1--random20; /*all variables that are between var1 and random20 if you look at the variables in a table*/

run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 03 Nov 2015 20:28:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-type-of-join/m-p/232963#M42485</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-11-03T20:28:25Z</dc:date>
    </item>
    <item>
      <title>Re: What type of join?</title>
      <link>https://communities.sas.com/t5/SAS-Programming/What-type-of-join/m-p/232979#M42497</link>
      <description>Thank you!!&lt;BR /&gt;</description>
      <pubDate>Tue, 03 Nov 2015 21:19:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/What-type-of-join/m-p/232979#M42497</guid>
      <dc:creator>jenim514</dc:creator>
      <dc:date>2015-11-03T21:19:11Z</dc:date>
    </item>
  </channel>
</rss>

