<?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 Join error? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-Join-error/m-p/464541#M70520</link>
    <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp;Your right. If you see my note I mentioned&amp;nbsp;&lt;STRONG&gt;Make sure you have all the columns selected in sub-query that are referenced in main query.&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 23 May 2018 19:28:22 GMT</pubDate>
    <dc:creator>SuryaKiran</dc:creator>
    <dc:date>2018-05-23T19:28:22Z</dc:date>
    <item>
      <title>PROC SQL Join error?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-Join-error/m-p/464493#M70510</link>
      <description>&lt;P&gt;Hi all:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I know it looks a little crazy and greedy. &lt;img id="cattongue" class="emoticon emoticon-cattongue" src="https://communities.sas.com/i/smilies/16x16_cat-tongue.png" alt="Cat Tongue" title="Cat Tongue" /&gt;&amp;nbsp; I was trying to use PROC SQL&amp;nbsp;inner join for merge 12 tables in&amp;nbsp;ONE based on their same ID.&amp;nbsp; However, the code didn't work.&amp;nbsp; Any suggestion?&amp;nbsp; Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
	CREATE TABLE test AS
	SELECT a.ID,
  a.Display_label,
  a.Crowdingpercent&amp;amp;year.,
  b.LowEducationpercent&amp;amp;year.,
  b.&lt;BR /&gt;.
. &lt;BR /&gt; l.AffordHousing_M&amp;amp;year.,
  l.AffordHousing_NoM&amp;amp;year.
	FROM crowding&amp;amp;year.  a inner JOIN
	education&amp;amp;year.  b inner JOIN
  .&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;.&lt;BR /&gt;.
  
  affordableHousing&amp;amp;year.  l
	ON a.ID = b.ID = c.ID = d.ID = e.ID = f.ID = g.ID = h.ID = i.ID = j.ID = k.ID = l.ID
	ORDER BY ID;
QUIT;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 May 2018 19:43:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-Join-error/m-p/464493#M70510</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2018-05-23T19:43:55Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL Join error?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-Join-error/m-p/464497#M70511</link>
      <description>&lt;P&gt;Check you syntax:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	FROM crowding&amp;amp;year.  a 
		inner JOIN education&amp;amp;year.  b ON a.ID = b.ID
		inner JOIN workercls&amp;amp;year.  c ON a.ID = c.ID
		inner JOIN occupation&amp;amp;year. d ON a.ID = d.ID 
		inner JOIN poverty&amp;amp;year.    e ON a.ID = e.ID
                ..............So on
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 May 2018 18:09:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-Join-error/m-p/464497#M70511</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-05-23T18:09:43Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL Join error?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-Join-error/m-p/464510#M70514</link>
      <description>&lt;P&gt;Thanks.&amp;nbsp; However, I found the ID are duplicated in the new combined table.&amp;nbsp; I have to add NODUPKEY step to fix it.&amp;nbsp;&amp;nbsp; Is there a way to just do it in SQL step?&amp;nbsp; Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 23 May 2018 18:35:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-Join-error/m-p/464510#M70514</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2018-05-23T18:35:12Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL Join error?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-Join-error/m-p/464516#M70515</link>
      <description>&lt;P&gt;Then at least one of your initial tables must have a duplicate ID, right?&amp;nbsp; It might be better to first eliminate duplicates from the contributing table if you can come up with a criterion that doesn't need data from other tables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 May 2018 18:42:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-Join-error/m-p/464516#M70515</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-05-23T18:42:26Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL Join error?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-Join-error/m-p/464519#M70516</link>
      <description>&lt;P&gt;You can remove duplicated by DISTINCT keyword&amp;nbsp;in sub-query. Make sure you have all the columns selected in sub-query that are referenced in main query.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;FROM crowding&amp;amp;year.  a 
		inner JOIN ( select distinct Display_label,Crowdingpercent&amp;amp;year.
                                   FROM education&amp;amp;year.) b ON a.ID = b.ID 
                inner JOIN workercls&amp;amp;year. c ON a.ID = c.ID 
                inner JOIN occupation&amp;amp;year. d ON a.ID = d.ID 
                inner JOIN poverty&amp;amp;year. e ON a.ID = e.ID ..............So on&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 23 May 2018 18:50:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-Join-error/m-p/464519#M70516</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-05-23T18:50:47Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL Join error?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-Join-error/m-p/464530#M70517</link>
      <description>&lt;P&gt;Could you append the data sets instead, add in a year column and then use TRANSPOSE to create the giant wide data set you want? The wide data set would be painful to work with anyways, so in general a vertical stacked data set may be preferable.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/67134"&gt;@ybz12003&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi all:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I know it looks a little crazy and greedy. &lt;img id="cattongue" class="emoticon emoticon-cattongue" src="https://communities.sas.com/i/smilies/16x16_cat-tongue.png" alt="Cat Tongue" title="Cat Tongue" /&gt;&amp;nbsp; I was trying to use PROC SQL&amp;nbsp;inner join for merge 12 tables in&amp;nbsp;ONE based on their same ID.&amp;nbsp; However, the code didn't work.&amp;nbsp; Any suggestion?&amp;nbsp; Thanks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC SQL;
	CREATE TABLE test AS
	SELECT a.ID,
  a.Display_label,
  a.Crowdingpercent&amp;amp;year.,
  b.LowEducationpercent&amp;amp;year.,
  b.HighEducationpercent&amp;amp;year.,
  c.LowworkclsPercent&amp;amp;year.,
  d.Occupationpercent&amp;amp;year.,
  e.PovertyPercent&amp;amp;year.,
  f.RentalOccupancyPercent&amp;amp;year.,
  g.WealthHomepercent&amp;amp;year.,
  h.Unemploypercent&amp;amp;year.,
  i.MedianIncome&amp;amp;year.,
  j.Language2ndPercent&amp;amp;year.,
  k.White__P&amp;amp;year.,
  k.AA_P&amp;amp;year.,
  k.AIAN__P&amp;amp;year.,
  k.__P&amp;amp;year.,
  k.PI_P&amp;amp;year.,
  k.Other__P&amp;amp;year.,
  k.TwoPlus_P&amp;amp;year.,
  l.AffordHousing_M&amp;amp;year.,
  l.AffordHousing_NoM&amp;amp;year.
	FROM crowding&amp;amp;year.  a inner JOIN
	education&amp;amp;year.  b inner JOIN
  workercls&amp;amp;year.  c inner JOIN
  occupation&amp;amp;year.  d inner JOIN
  poverty&amp;amp;year.  e inner JOIN
  rentaloccupancy&amp;amp;year.  f inner JOIN
  wealthhome&amp;amp;year.  g inner JOIN
  unemploy&amp;amp;year.  h inner JOIN
  medianincome&amp;amp;year.  i inner JOIN
  language&amp;amp;year.  j inner JOIN
  race&amp;amp;year.  k inner JOIN
  affordableHousing&amp;amp;year.  l
	ON a.ID = b.ID = c.ID = d.ID = e.ID = f.ID = g.ID = h.ID = i.ID = j.ID = k.ID = l.ID
	ORDER BY ID;
QUIT;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 May 2018 19:02:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-Join-error/m-p/464530#M70517</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-05-23T19:02:03Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL Join error?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-Join-error/m-p/464535#M70518</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/83078"&gt;@SuryaKiran&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I believe your suggestion would generate an&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;&amp;nbsp; "ERROR: Column ID could not be found in the table/view identified with the correlation name b."&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;message, because the sub-query doesn't include ID.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And if the subquery did include ID,as in&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;STRONG&gt;&lt;SPAN class="token punctuation"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; (&lt;/SPAN&gt;&lt;SPAN class="token statement"&gt;select&lt;/SPAN&gt; &lt;SPAN class="token keyword"&gt;distinct&lt;/SPAN&gt; ID, Display_label&lt;SPAN class="token punctuation"&gt;,&lt;/SPAN&gt;Crowdingpercent&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;year&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN class="token keyword"&gt;FROM&lt;/SPAN&gt; education&lt;SPAN class="token operator"&gt;&amp;amp;&lt;/SPAN&gt;&lt;SPAN class="token function"&gt;year&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;.&lt;/SPAN&gt;&lt;SPAN class="token punctuation"&gt;)&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN class="token punctuation"&gt;the OP could still get duplicate ID's in the resulting table, unless it is known that all instances of duplicate ID's in the education&amp;amp;year table will also have duplicate Display_label,Crowdingpercent&amp;amp;year values.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 May 2018 19:16:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-Join-error/m-p/464535#M70518</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2018-05-23T19:16:57Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL Join error?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-Join-error/m-p/464537#M70519</link>
      <description>&lt;P&gt;Thanks, Suryakiran!&amp;nbsp; It works.&lt;/P&gt;</description>
      <pubDate>Wed, 23 May 2018 19:20:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-Join-error/m-p/464537#M70519</guid>
      <dc:creator>ybz12003</dc:creator>
      <dc:date>2018-05-23T19:20:29Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SQL Join error?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-Join-error/m-p/464541#M70520</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/31461"&gt;@mkeintz&lt;/a&gt;&amp;nbsp;Your right. If you see my note I mentioned&amp;nbsp;&lt;STRONG&gt;Make sure you have all the columns selected in sub-query that are referenced in main query.&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 23 May 2018 19:28:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/PROC-SQL-Join-error/m-p/464541#M70520</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-05-23T19:28:22Z</dc:date>
    </item>
  </channel>
</rss>

