<?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 (while 1 has single record others has copies of many with out using prc sort before) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/merge-while-1-has-single-record-others-has-copies-of-many-with/m-p/649966#M194890</link>
    <description>&lt;P&gt;Alright, never mind. I give in to you that you are correct. The way I understand you want all the ID's in AA&amp;nbsp; whether or not it matches with those in BB. I would like you to tell what kind of JOIN/LOOK UP would you consider?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I believe once the above is clear, that should pave way for a right syntax or SAS/SQL words&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 22 May 2020 17:43:06 GMT</pubDate>
    <dc:creator>novinosrin</dc:creator>
    <dc:date>2020-05-22T17:43:06Z</dc:date>
    <item>
      <title>merge (while 1 has single record others has copies of many with out using prc sort before)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merge-while-1-has-single-record-others-has-copies-of-many-with/m-p/649960#M194885</link>
      <description>&lt;P&gt;Hi experts,&lt;/P&gt;
&lt;P&gt;I've 2 datasets,&amp;nbsp; TABLE "AA" looks like:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;id&amp;nbsp; &amp;nbsp; &amp;nbsp;WT&lt;/P&gt;
&lt;P&gt;011 84.9&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;012 76.9&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;013 54.9&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;TABLE "BB looks like"&lt;/P&gt;
&lt;P&gt;id&amp;nbsp; &amp;nbsp; &amp;nbsp; record&amp;nbsp; sysbp diabp hr&lt;/P&gt;
&lt;P&gt;011&amp;nbsp; &amp;nbsp;yes&amp;nbsp; &amp;nbsp; &amp;nbsp;133&amp;nbsp; &amp;nbsp; &amp;nbsp; 87&amp;nbsp; &amp;nbsp; 73&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;011&amp;nbsp; &amp;nbsp;yes&amp;nbsp; &amp;nbsp; &amp;nbsp;133&amp;nbsp; &amp;nbsp; &amp;nbsp; 87&amp;nbsp; &amp;nbsp; 73&lt;/P&gt;
&lt;P&gt;011&amp;nbsp; &amp;nbsp;yes&amp;nbsp; &amp;nbsp; &amp;nbsp;133&amp;nbsp; &amp;nbsp; &amp;nbsp; 87&amp;nbsp; &amp;nbsp; 73&lt;/P&gt;
&lt;P&gt;012&amp;nbsp; &amp;nbsp;yes&amp;nbsp; &amp;nbsp; &amp;nbsp;130&amp;nbsp; &amp;nbsp; &amp;nbsp; 89&amp;nbsp; &amp;nbsp; 71&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;012&amp;nbsp; &amp;nbsp;yes&amp;nbsp; &amp;nbsp; &amp;nbsp;130&amp;nbsp; &amp;nbsp; &amp;nbsp; 89&amp;nbsp; &amp;nbsp; 71&lt;/P&gt;
&lt;P&gt;012&amp;nbsp; &amp;nbsp;yes&amp;nbsp; &amp;nbsp; &amp;nbsp;130&amp;nbsp; &amp;nbsp; &amp;nbsp; 89&amp;nbsp; &amp;nbsp; 71&lt;/P&gt;
&lt;P&gt;013&amp;nbsp; &amp;nbsp;yes&amp;nbsp; &amp;nbsp; &amp;nbsp;121&amp;nbsp; &amp;nbsp; &amp;nbsp; 77&amp;nbsp; &amp;nbsp; 83&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;013&amp;nbsp; &amp;nbsp;yes&amp;nbsp; &amp;nbsp; &amp;nbsp;121&amp;nbsp; &amp;nbsp; &amp;nbsp; 77&amp;nbsp; &amp;nbsp; 83&lt;/P&gt;
&lt;P&gt;013&amp;nbsp; &amp;nbsp;yes&amp;nbsp; &amp;nbsp; &amp;nbsp;121&amp;nbsp; &amp;nbsp; &amp;nbsp; 77&amp;nbsp; &amp;nbsp; 83&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;i would like to merge them so that the final data set should have(as we have the unique values in triplicates in "BB" table)&lt;/P&gt;
&lt;P&gt;id&amp;nbsp; &amp;nbsp; &amp;nbsp;WT&amp;nbsp; &amp;nbsp;sysbp&amp;nbsp; diabp&amp;nbsp; hr&lt;/P&gt;
&lt;P&gt;011 84.9&amp;nbsp;&amp;nbsp;133&amp;nbsp; &amp;nbsp; &amp;nbsp; 87&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;73&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;012 76.9&amp;nbsp;&amp;nbsp;130&amp;nbsp; &amp;nbsp; &amp;nbsp; 89&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;71&lt;/P&gt;
&lt;P&gt;013 54.9&amp;nbsp;&amp;nbsp;121&amp;nbsp; &amp;nbsp; &amp;nbsp; 77&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;83&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;please let me know if the result table can be achieved with out need of a prior or post nodupkey procedure?is there a direct option available in data step or by proc sql can we achieve it in a single step?&lt;/P&gt;
&lt;P&gt;for merge i do use if a=1 as i write merge aa(in=a) bb(in=b).&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any suggestions are welcome.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 May 2020 17:20:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merge-while-1-has-single-record-others-has-copies-of-many-with/m-p/649960#M194885</guid>
      <dc:creator>sahoositaram555</dc:creator>
      <dc:date>2020-05-22T17:20:41Z</dc:date>
    </item>
    <item>
      <title>Re: merge (while 1 has single record others has copies of many with out using prc sort before)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merge-while-1-has-single-record-others-has-copies-of-many-with/m-p/649961#M194886</link>
      <description>&lt;P&gt;Hi I am not sure what's the challenge in this task as it seems much too straight forward&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
data aa;
input id $    WT;
cards;
011 84.9  
012 76.9  
013 54.9  
;

data bb;
input id $  record $ sysbp diabp hr;
cards;
011   yes     133      87    73  

011   yes     133      87    73

011   yes     133      87    73

012   yes     130      89    71  

012   yes     130      89    71

012   yes     130      89    71

013   yes     121      77    83  

013   yes     121      77    83

013   yes     121      77    83
;

data want;
merge aa bb;
by id;
if first.id;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;Or even with SQL&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sql;
create table want as
select distinct aa.*,record,sysbp,diabp, hr
from aa,bb
where aa.id=bb.id;
quit;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 May 2020 17:29:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merge-while-1-has-single-record-others-has-copies-of-many-with/m-p/649961#M194886</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-05-22T17:29:38Z</dc:date>
    </item>
    <item>
      <title>Re: merge (while 1 has single record others has copies of many with out using prc sort before)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merge-while-1-has-single-record-others-has-copies-of-many-with/m-p/649962#M194887</link>
      <description>&lt;P&gt;You really should include an example of the desired output if any of the records in "BB" have different values of sysbp diabp hr for an Id value.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Which I strongly suspect is more likely given that the variables appear to be related to blood pressure readings.&lt;/P&gt;</description>
      <pubDate>Fri, 22 May 2020 17:32:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merge-while-1-has-single-record-others-has-copies-of-many-with/m-p/649962#M194887</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-05-22T17:32:36Z</dc:date>
    </item>
    <item>
      <title>Re: merge (while 1 has single record others has copies of many with out using prc sort before)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merge-while-1-has-single-record-others-has-copies-of-many-with/m-p/649963#M194888</link>
      <description>Hi, Thank your very much. There is a challenge. In BB i have many other id's which i dont want them in my final dataset , so with ur solution for data step probaly i can define in= procedure for both the datasets and can do if a=1 and first.id, but how to the similar thing in sql is something that i'm not aware of.It would be great to have ur reply.</description>
      <pubDate>Fri, 22 May 2020 17:37:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merge-while-1-has-single-record-others-has-copies-of-many-with/m-p/649963#M194888</guid>
      <dc:creator>sahoositaram555</dc:creator>
      <dc:date>2020-05-22T17:37:06Z</dc:date>
    </item>
    <item>
      <title>Re: merge (while 1 has single record others has copies of many with out using prc sort before)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merge-while-1-has-single-record-others-has-copies-of-many-with/m-p/649966#M194890</link>
      <description>&lt;P&gt;Alright, never mind. I give in to you that you are correct. The way I understand you want all the ID's in AA&amp;nbsp; whether or not it matches with those in BB. I would like you to tell what kind of JOIN/LOOK UP would you consider?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I believe once the above is clear, that should pave way for a right syntax or SAS/SQL words&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 May 2020 17:43:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merge-while-1-has-single-record-others-has-copies-of-many-with/m-p/649966#M194890</guid>
      <dc:creator>novinosrin</dc:creator>
      <dc:date>2020-05-22T17:43:06Z</dc:date>
    </item>
    <item>
      <title>Re: merge (while 1 has single record others has copies of many with out using prc sort before)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/merge-while-1-has-single-record-others-has-copies-of-many-with/m-p/649995#M194902</link>
      <description>&lt;PRE&gt;proc sql;
create table want as
select distinct aa.*,record,sysbp,diabp, hr
from aa   
        left join
        bb
 on aa.id=bb.id;
quit;&lt;/PRE&gt;
&lt;P&gt;The Left Join says you want all the records from AA (the set that comes before Left) and matches the second set only when the ON condition is met.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A Where is applied to results of previous steps.&lt;/P&gt;</description>
      <pubDate>Fri, 22 May 2020 19:30:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/merge-while-1-has-single-record-others-has-copies-of-many-with/m-p/649995#M194902</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2020-05-22T19:30:16Z</dc:date>
    </item>
  </channel>
</rss>

