<?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: Merging in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Merging/m-p/609214#M177360</link>
    <description>&lt;P&gt;thanks,&amp;nbsp; this worked&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 04 Dec 2019 00:14:54 GMT</pubDate>
    <dc:creator>Tal</dc:creator>
    <dc:date>2019-12-04T00:14:54Z</dc:date>
    <item>
      <title>Merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging/m-p/596719#M171862</link>
      <description>&lt;P&gt;Hi,&amp;nbsp; i have&amp;nbsp; 2&amp;nbsp; tables (one has the entire&amp;nbsp; &amp;nbsp;population and the other&amp;nbsp; some updates&amp;nbsp; which i merge and create another variable "score"&lt;/P&gt;
&lt;P&gt;if the person is white and is not in table b then score=score1&amp;nbsp; otherwise score=score2&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;table a:&lt;BR /&gt;city dob name race score1 &lt;BR /&gt;---------------------------------&lt;BR /&gt;nyc 22jan2001 tom white 66 &lt;BR /&gt;paris 11feb1994 piere white 33&lt;BR /&gt;berlin 11feb1994 mark white 36&lt;BR /&gt;milan 22jan1996 Mike black 30&lt;BR /&gt;milan 22jan1996 Moe black 40&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;table b:&lt;BR /&gt;city dob name race score2 &lt;BR /&gt;---------------------------------&lt;BR /&gt;nyc 22jan2001 tom white 11&lt;BR /&gt;paris 11feb1994 piere white 17&lt;BR /&gt;milan 22jan1996 Mike black 35&lt;BR /&gt;milan 22jan1996 Moe black 37&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;the final&amp;nbsp; table will have to look like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;nyc 22jan2001 tom white 11&lt;BR /&gt;paris 11feb1994 piere white 17&lt;/P&gt;
&lt;P&gt;berlin 11feb1994 mark white 36&lt;BR /&gt;milan 22jan1996 Mike black 35&lt;/P&gt;
&lt;P&gt;milan 22jan1996 Moe black 37&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;is there a better, more efficient way/quicker method i can use to achieve this?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;All i could&amp;nbsp; think of was&amp;nbsp; this below but these tables&amp;nbsp; are huge so not&amp;nbsp; sure this is a&amp;nbsp; good approach so&amp;nbsp; if anyone&amp;nbsp; can&amp;nbsp; think of a better approach please share it with me.&amp;nbsp; Thanks&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;key=cats(city,dob,name,race);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data final1 final2;&lt;BR /&gt;merge tablea(in=a) tableb(in=b);&lt;BR /&gt;by key;&lt;BR /&gt;if a and not b and race='white' then do;score=score1;output final1;end;&lt;BR /&gt;else do;score=score2; output final2;end;run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data final(drop= key score1 score2);&lt;BR /&gt;set final1 final2;run;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2019 02:42:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging/m-p/596719#M171862</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2019-10-16T02:42:06Z</dc:date>
    </item>
    <item>
      <title>Re: Merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging/m-p/596727#M171864</link>
      <description>&lt;P&gt;Look at the UPDATE statement instead of the MERGE statement.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2019 03:03:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging/m-p/596727#M171864</guid>
      <dc:creator>ChrisNZ</dc:creator>
      <dc:date>2019-10-16T03:03:18Z</dc:date>
    </item>
    <item>
      <title>Re: Merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging/m-p/596744#M171868</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/34400"&gt;@Tal&lt;/a&gt;:&lt;/P&gt;
&lt;P&gt;Sure, you can do more efficiently - id est, without needing to sort, e.g.:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data a ;                                                                                                                                
  input city $ dob :date. name $ race $ score1 ;                                                                                        
  cards ;                                                                                                                               
nyc    22jan2001 tom   white 66                                                                                                         
paris  11feb1994 piere white 33                                                                                                         
berlin 11feb1994 mark  white 36                                                                                                         
milan  22jan1996 mike  black 30                                                                                                         
milan  22jan1996 moe   black 40                                                                                                         
;                                                                                                                                       
run ;                                                                                                                                   
                                                                                                                                        
data b ;                                                                                                                                
  input city $ dob :date. name $ race $ score2 ;                                                                                        
  cards ;                                                                                                                               
nyc   22jan2001 tom   white 11                                                                                                          
paris 11feb1994 piere white 17                                                                                                          
milan 22jan1996 mike  black 35                                                                                                          
milan 22jan1996 moe   black 37                                                                                                          
;                                                                                                                                       
run ;                                                                                                                                   
                                                                                                                                        
data want ;                                                                                                                             
  if _n_ = 1 then do ;                                                                                                                  
    dcl hash h (dataset: "b (rename=score2=score)") ;                                                                                   
    h.definekey ("city","dob","name","race") ;                                                                                          
    h.definedata ("score") ;                                                                                                            
    h.definedone () ;                                                                                                                   
  end ;                                                                                                                                 
  set a (rename=score1=score) ;                                                                                                         
  _iorc_ = h.find() ;                                                                                                                   
  format dob yymmdd10. ;                                                                                                                
run ;                          
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Kind regards&lt;/P&gt;
&lt;P&gt;Paul D.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2019 04:56:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging/m-p/596744#M171868</guid>
      <dc:creator>hashman</dc:creator>
      <dc:date>2019-10-16T04:56:57Z</dc:date>
    </item>
    <item>
      <title>Re: Merging</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Merging/m-p/609214#M177360</link>
      <description>&lt;P&gt;thanks,&amp;nbsp; this worked&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Dec 2019 00:14:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Merging/m-p/609214#M177360</guid>
      <dc:creator>Tal</dc:creator>
      <dc:date>2019-12-04T00:14:54Z</dc:date>
    </item>
  </channel>
</rss>

