<?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 merge two tables by two common variables in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/how-to-merge-two-tables-by-two-common-variables/m-p/157741#M41310</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If this is the exact code submitted you are missing a ; after the dataset name (or at least before the BY statement).&lt;/P&gt;&lt;P&gt;proc sort data=Institution&lt;/P&gt;&lt;P&gt;by ID Sharetypr;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 05 Nov 2014 15:49:46 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2014-11-05T15:49:46Z</dc:date>
    <item>
      <title>how to merge two tables by two common variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-merge-two-tables-by-two-common-variables/m-p/157739#M41308</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Dear everyone,&lt;/P&gt;&lt;P&gt;I tried to merge two datasets, using "proc sql". Two datasets have two common variables: ID and Sharetype. Below is my code:&lt;/P&gt;&lt;P&gt;proc sort data=Institution&lt;/P&gt;&lt;P&gt;by ID Sharetypr;&lt;/P&gt;&lt;P&gt;proc sort data=Stock;&lt;/P&gt;&lt;P&gt;by ID sharetype;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;create table Institution_Stock as &lt;/P&gt;&lt;P&gt;select L.*, R.*&lt;/P&gt;&lt;P&gt;from Institution as L&lt;/P&gt;&lt;P&gt;LEFT JOIN Stock as R &lt;/P&gt;&lt;P&gt;on L.ID=R.ID and L.sharetype=R.sharetype;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The sort part is run without any error, but when I run the proc sql I receive this error:&lt;/P&gt;&lt;P&gt;"ERROR: Sort execution failure."&lt;/P&gt;&lt;P&gt;I have no idea what's the problem. I appreciate if you help me.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Nov 2014 15:30:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-merge-two-tables-by-two-common-variables/m-p/157739#M41308</guid>
      <dc:creator>m1986MM</dc:creator>
      <dc:date>2014-11-05T15:30:22Z</dc:date>
    </item>
    <item>
      <title>Re: how to merge two tables by two common variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-merge-two-tables-by-two-common-variables/m-p/157740#M41309</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Well firstly you do not need to pre-sort datasets, SQL does not expect pre-sorted datasets.&amp;nbsp; Now your SQL:&lt;/P&gt;&lt;P&gt;proc sql;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; create table Institution_Stock as&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; select&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; L.*,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; R.*&amp;nbsp;&amp;nbsp;&amp;nbsp; /* You don't want to do this as variables appear in both datasets */&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; from Institution L&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; left join&amp;nbsp; Stock R&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; on L.ID=R.ID&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and L.sharetype=R.sharetype;&lt;/P&gt;&lt;P&gt;quit;&lt;/P&gt;&lt;P&gt;The above should work on unsorted datasets, if it doesn't post some test data. (note you will get a warning per my comment about r.*).&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Nov 2014 15:44:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-merge-two-tables-by-two-common-variables/m-p/157740#M41309</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-11-05T15:44:45Z</dc:date>
    </item>
    <item>
      <title>Re: how to merge two tables by two common variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-merge-two-tables-by-two-common-variables/m-p/157741#M41310</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;If this is the exact code submitted you are missing a ; after the dataset name (or at least before the BY statement).&lt;/P&gt;&lt;P&gt;proc sort data=Institution&lt;/P&gt;&lt;P&gt;by ID Sharetypr;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Nov 2014 15:49:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-merge-two-tables-by-two-common-variables/m-p/157741#M41310</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2014-11-05T15:49:46Z</dc:date>
    </item>
    <item>
      <title>Re: how to merge two tables by two common variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-merge-two-tables-by-two-common-variables/m-p/157742#M41311</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;As my colleagues have already pointed out, your first proc sort call is missing a semicolon. Additionally, in your first proc sort call you misspelled &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Sharetype as &lt;SPAN style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;Sharetypr. And, as they also pointed out, your data doesn't have to be sorted in order to run proc sql.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your sql code, I think, will run as is!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Nov 2014 15:56:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-merge-two-tables-by-two-common-variables/m-p/157742#M41311</guid>
      <dc:creator>art297</dc:creator>
      <dc:date>2014-11-05T15:56:54Z</dc:date>
    </item>
    <item>
      <title>Re: how to merge two tables by two common variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-merge-two-tables-by-two-common-variables/m-p/157743#M41312</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;No I changed the name of the variables here to make more sense. It's a typo.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Nov 2014 16:01:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-merge-two-tables-by-two-common-variables/m-p/157743#M41312</guid>
      <dc:creator>m1986MM</dc:creator>
      <dc:date>2014-11-05T16:01:11Z</dc:date>
    </item>
    <item>
      <title>Re: how to merge two tables by two common variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-merge-two-tables-by-two-common-variables/m-p/157744#M41313</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry! I didn't get the difference. You omitted the "as", like as L or as R. Is that the case&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Nov 2014 16:04:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-merge-two-tables-by-two-common-variables/m-p/157744#M41313</guid>
      <dc:creator>m1986MM</dc:creator>
      <dc:date>2014-11-05T16:04:53Z</dc:date>
    </item>
    <item>
      <title>Re: how to merge two tables by two common variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-merge-two-tables-by-two-common-variables/m-p/157745#M41314</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There isn't much difference, I point out that doing R.* will give you warnings as variables exist in two different datasets.&amp;nbsp; You can put AS in if you like, I tend to not do that, just a preference.&amp;nbsp; Per my message, you don't need the sorts so just run the code.&amp;nbsp; If you get errors other than variable appears in both tables, then please post some test data and the full warning without spelling mistakes, also stating what version/install of SAS you have, is it server based/locally installed.&amp;nbsp; If you still get the error then perhaps something on this page will help; &lt;A href="http://support.sas.com/kb/39/705.html"&gt;http://support.sas.com/kb/39/705.html&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Nov 2014 16:19:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-merge-two-tables-by-two-common-variables/m-p/157745#M41314</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2014-11-05T16:19:57Z</dc:date>
    </item>
    <item>
      <title>Re: how to merge two tables by two common variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-merge-two-tables-by-two-common-variables/m-p/157746#M41315</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Why not just do a merge instead of using PROC SQL ??&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;data Institution_Stock;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&amp;nbsp; merge &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Institution (in=in1) &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;Stock ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp; by &lt;/SPAN&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;ID sharetype ;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp;&amp;nbsp; if in1;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; background-color: #ffffff;"&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;run;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Nov 2014 18:51:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-merge-two-tables-by-two-common-variables/m-p/157746#M41315</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2014-11-05T18:51:25Z</dc:date>
    </item>
    <item>
      <title>Re: how to merge two tables by two common variables</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/how-to-merge-two-tables-by-two-common-variables/m-p/157747#M41316</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi m,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As everyone said above, if there are no typo's your code should work as is or this could be a memory issue too. The below SAS notes might help in fixing the error&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A href="http://support.sas.com/kb/39/705.html" title="http://support.sas.com/kb/39/705.html"&gt;39705 - Troubleshooting Sort Initialization and Sort Execution Failure errors in SQL procedures in Windows and UNIX environments&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 05 Nov 2014 20:12:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/how-to-merge-two-tables-by-two-common-variables/m-p/157747#M41316</guid>
      <dc:creator>sasjourney</dc:creator>
      <dc:date>2014-11-05T20:12:58Z</dc:date>
    </item>
  </channel>
</rss>

