<?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: Merge.. in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Merge/m-p/501541#M528</link>
    <description>&lt;P&gt;I don't see an actual value for subscriber_no in&amp;nbsp; your example data?&lt;/P&gt;</description>
    <pubDate>Thu, 04 Oct 2018 15:40:57 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2018-10-04T15:40:57Z</dc:date>
    <item>
      <title>Merge..</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Merge/m-p/501539#M527</link>
      <description>&lt;P&gt;I have a table “A” with details like subscriber_no, name, age, occupation&lt;/P&gt;&lt;P&gt;Eg of one of the records : Adam, 35, Data Analyst&lt;/P&gt;&lt;P&gt;And table “B” with similar info subscriber_no, name, age, occupation &amp;nbsp;and AN EXTRA COLUMN named CITY&lt;/P&gt;&lt;P&gt;Eg: Adam, 30, Director, Toronto&lt;/P&gt;&lt;P&gt;Ella, 40, Manager, Vancouver&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want the info in the final merged table as :&lt;/P&gt;&lt;P&gt;if the subscriber_no exists in table A, take all the information for that subscriber from table A&lt;/P&gt;&lt;P&gt;and just add the CITY : Toronto to it&lt;/P&gt;&lt;P&gt;say, Name : Adam, 35, Data Analyst, Toronto&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do not want the info from B at all EXCEPT adding CITY if the subscriber no exists in A.&lt;/P&gt;&lt;P&gt;However, if the subscriber no does not exist in A then I want all information about it from B&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So the final tbale should look like:&lt;/P&gt;&lt;P&gt;Adam, 35, Data Analyst, Toronto&lt;/P&gt;&lt;P&gt;Ella, 40, Manager, Vancouver&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I achieve this?&lt;/P&gt;&lt;P&gt;Thanks in advance:)&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2018 15:35:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Merge/m-p/501539#M527</guid>
      <dc:creator>new_sas_user_4</dc:creator>
      <dc:date>2018-10-04T15:35:06Z</dc:date>
    </item>
    <item>
      <title>Re: Merge..</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Merge/m-p/501541#M528</link>
      <description>&lt;P&gt;I don't see an actual value for subscriber_no in&amp;nbsp; your example data?&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2018 15:40:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Merge/m-p/501541#M528</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2018-10-04T15:40:57Z</dc:date>
    </item>
    <item>
      <title>Re: Merge..</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Merge/m-p/501545#M529</link>
      <description>&lt;P&gt;Do a left join&amp;nbsp;&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 a.*,b.city
from tableA a
left join tableB b on (a.name=b.name);
quit;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;If your real data is joining by name, then what if you have multiple people with same names (mostly possible)?&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2018 15:42:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Merge/m-p/501545#M529</guid>
      <dc:creator>SuryaKiran</dc:creator>
      <dc:date>2018-10-04T15:42:26Z</dc:date>
    </item>
    <item>
      <title>Re: Merge..</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Merge/m-p/501548#M530</link>
      <description>&lt;P&gt;Table A&lt;/P&gt;&lt;P&gt;001,&lt;SPAN&gt;Adam, 35, Data Analyst&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Table B&lt;/P&gt;&lt;P&gt;001,&lt;SPAN&gt;Adam, 30, Director, Toronto&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;002, Ella, 40, Manager, Vancouver&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want Table C(final table) as&amp;nbsp;&lt;/P&gt;&lt;P&gt;001,Adam, 35, Data Analyst, Toronto&lt;/P&gt;&lt;P&gt;002, Ella, 40, Manager, Vancouver&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Left join wont get me the subs from table B(which arent in table A)&lt;/P&gt;&lt;P&gt;there are no duplicate names/subscriber no&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2018 15:47:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Merge/m-p/501548#M530</guid>
      <dc:creator>new_sas_user_4</dc:creator>
      <dc:date>2018-10-04T15:47:44Z</dc:date>
    </item>
    <item>
      <title>Re: Merge..</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Merge/m-p/501553#M531</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/213838"&gt;@new_sas_user_4&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;I have a table “A” with details like subscriber_no, name, age, occupation&lt;/P&gt;
&lt;P&gt;Eg of one of the records : Adam, 35, Data Analyst&lt;/P&gt;
&lt;P&gt;And table “B” with similar info subscriber_no, name, age, occupation &amp;nbsp;and AN EXTRA COLUMN named CITY&lt;/P&gt;
&lt;P&gt;Eg: Adam, 30, Director, Toronto&lt;/P&gt;
&lt;P&gt;Ella, 40, Manager, Vancouver&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want the info in the final merged table as :&lt;/P&gt;
&lt;P&gt;if the subscriber_no exists in table A, take all the information for that subscriber from table A&lt;/P&gt;
&lt;P&gt;and just add the CITY : Toronto to it&lt;/P&gt;
&lt;P&gt;say, Name : Adam, 35, Data Analyst, Toronto&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I do not want the info from B at all EXCEPT adding CITY if the subscriber no exists in A.&lt;/P&gt;
&lt;P&gt;However, if the subscriber no does not exist in A then I want all information about it from B&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So the final tbale should look like:&lt;/P&gt;
&lt;P&gt;Adam, 35, Data Analyst, Toronto&lt;/P&gt;
&lt;P&gt;Ella, 40, Manager, Vancouver&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I achieve this?&lt;/P&gt;
&lt;P&gt;Thanks in advance:)&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Are the values for subscriber_no, name, age, occupation duplicated within table A? If not perhaps:&lt;/P&gt;
&lt;PRE&gt;proc sort data=tablea;
   by subscriber_no name age occupation;
run;

proc sort data=tableb;
   by subscriber_no name age occupation;
run;

data want;
   update tablea
          tableb(keep = subscriber_no name age occupation city)
   ;
   by subscriber_no name age occupation;
run;
&lt;/PRE&gt;</description>
      <pubDate>Thu, 04 Oct 2018 15:52:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Merge/m-p/501553#M531</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-10-04T15:52:23Z</dc:date>
    </item>
    <item>
      <title>Re: Merge..</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Merge/m-p/501566#M535</link>
      <description>&lt;P&gt;The aboev solution is giving the error:&lt;/P&gt;&lt;P&gt;BY variable CITY is not on input data set WORK.A&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Do both the data sets need to have the column CITY to use update statement?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, for the proc sort statement can I just use&amp;nbsp;&lt;/P&gt;&lt;P&gt;by subscriber_no&lt;/P&gt;&lt;P&gt;instead of subsriber_no name age occupation(all variables) ??&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2018 16:15:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Merge/m-p/501566#M535</guid>
      <dc:creator>new_sas_user_4</dc:creator>
      <dc:date>2018-10-04T16:15:48Z</dc:date>
    </item>
    <item>
      <title>Re: Merge..</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Merge/m-p/501568#M536</link>
      <description>&lt;P&gt;This would be much easier to answer if you could provide a better sample input data set and expected output. You'll get a working answer much faster.&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/213838"&gt;@new_sas_user_4&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The aboev solution is giving the error:&lt;/P&gt;
&lt;P&gt;BY variable CITY is not on input data set WORK.A&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do both the data sets need to have the column CITY to use update statement?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, for the proc sort statement can I just use&amp;nbsp;&lt;/P&gt;
&lt;P&gt;by subscriber_no&lt;/P&gt;
&lt;P&gt;instead of subsriber_no name age occupation(all variables) ??&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2018 16:21:08 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Merge/m-p/501568#M536</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2018-10-04T16:21:08Z</dc:date>
    </item>
    <item>
      <title>Re: Merge..</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Merge/m-p/501576#M538</link>
      <description>&lt;P&gt;Please see the attached excel.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2018 16:38:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Merge/m-p/501576#M538</guid>
      <dc:creator>new_sas_user_4</dc:creator>
      <dc:date>2018-10-04T16:38:01Z</dc:date>
    </item>
    <item>
      <title>Re: Merge..</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Merge/m-p/501608#M545</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/213838"&gt;@new_sas_user_4&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;The aboev solution is giving the error:&lt;/P&gt;
&lt;P&gt;BY variable CITY is not on input data set WORK.A&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Do both the data sets need to have the column CITY to use update statement?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also, for the proc sort statement can I just use&amp;nbsp;&lt;/P&gt;
&lt;P&gt;by subscriber_no&lt;/P&gt;
&lt;P&gt;instead of subsriber_no name age occupation(all variables) ??&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;&lt;STRONG&gt;&lt;/STRONG&gt;Try MERGE instead of update.&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2018 17:27:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Merge/m-p/501608#M545</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2018-10-04T17:27:54Z</dc:date>
    </item>
    <item>
      <title>Re: Merge..</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Merge/m-p/501620#M547</link>
      <description>&lt;P&gt;Using merge :&lt;/P&gt;&lt;P&gt;data C;&lt;/P&gt;&lt;P&gt;set A B;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;using this, it gives me tow rows for one subscriber&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 Adam 35 Data Analyst 1&amp;nbsp;&lt;/P&gt;&lt;P&gt;1 Adam 40 Director&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 1 Toronto&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think its because it takes the unique data from both A and B and therefore returns two rows.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 Oct 2018 17:46:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Merge/m-p/501620#M547</guid>
      <dc:creator>new_sas_user_4</dc:creator>
      <dc:date>2018-10-04T17:46:55Z</dc:date>
    </item>
  </channel>
</rss>

