<?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 SAS Dataset in SAS Data Management</title>
    <link>https://communities.sas.com/t5/SAS-Data-Management/Merge-SAS-Dataset/m-p/292420#M8287</link>
    <description>&lt;P&gt;The result you are describing looks like what you would get if you played with the program many times in many ways, in an attempt to get it to work. &amp;nbsp;What actually happened somewhere along the way was that the variables SSN and EMP_CD got added to the data set A (somewhere along the way). &amp;nbsp;Then when you merge, those values get read in and overwrite the values from data set B. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DROP the variables you don't need from the data set A. &amp;nbsp;That should take care of the problem.&lt;/P&gt;</description>
    <pubDate>Thu, 18 Aug 2016 12:15:46 GMT</pubDate>
    <dc:creator>Astounding</dc:creator>
    <dc:date>2016-08-18T12:15:46Z</dc:date>
    <item>
      <title>Merge SAS Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Merge-SAS-Dataset/m-p/292402#M8284</link>
      <description>&lt;P&gt;I have two datasets.&lt;/P&gt;&lt;P&gt;DATASET :- A&lt;/P&gt;&lt;P&gt;EE_ID &amp;nbsp; &amp;nbsp;PRJ_CD&lt;/P&gt;&lt;P&gt;100055 &amp;nbsp; 406&lt;/P&gt;&lt;P&gt;100055 &amp;nbsp; 475&lt;/P&gt;&lt;P&gt;100055 &amp;nbsp; 492&lt;/P&gt;&lt;P&gt;300028 &amp;nbsp; 475&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;DATASET :- B&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EE_ID &amp;nbsp; &amp;nbsp;SSN &amp;nbsp; &amp;nbsp; &amp;nbsp; EMP_CD&lt;/P&gt;&lt;P&gt;100055 0100055 &amp;nbsp; E&lt;/P&gt;&lt;P&gt;300028 0300028 &amp;nbsp; E&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have sorted &amp;amp; merged the above two datasets by EE_ID.&lt;/P&gt;&lt;P&gt;DATA&lt;BR /&gt;FINAL&lt;BR /&gt;;&lt;BR /&gt;MERGE&lt;BR /&gt;A&lt;/P&gt;&lt;P&gt;B ;&lt;BR /&gt;BY&lt;BR /&gt;EE_ID&lt;BR /&gt;;&lt;/P&gt;&lt;P&gt;IF A THEN OUTPUT;&lt;/P&gt;&lt;P&gt;RUN;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Output:-&lt;/P&gt;&lt;P&gt;EE_ID &amp;nbsp; &amp;nbsp; PRJ_CD &amp;nbsp; SSN &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;EMP_CD&lt;/P&gt;&lt;P&gt;100055 &amp;nbsp; &amp;nbsp;475&lt;BR /&gt;100055 &amp;nbsp; &amp;nbsp;492&lt;BR /&gt;100055 &amp;nbsp; &amp;nbsp;406 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0100055 &amp;nbsp; &amp;nbsp;E&lt;BR /&gt;300028 &amp;nbsp; &amp;nbsp;475 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0300028 &amp;nbsp; &amp;nbsp;E&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SSN and EMP_CD is getting populated for only one row and the remaining two rows are empty for the EE_ID 100055.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My expectation is :-&lt;/P&gt;&lt;P&gt;EE_ID &amp;nbsp; &amp;nbsp;PRJ_CD SSN &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;EMP_CD&lt;/P&gt;&lt;P&gt;100055 475 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0100055 &amp;nbsp; &amp;nbsp; E&lt;BR /&gt;100055 492 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0100055 &amp;nbsp; &amp;nbsp; E&lt;BR /&gt;100055 406 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0100055 &amp;nbsp; &amp;nbsp; E&lt;BR /&gt;300028 475 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 0300028 &amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2016 10:37:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Merge-SAS-Dataset/m-p/292402#M8284</guid>
      <dc:creator>AshokD</dc:creator>
      <dc:date>2016-08-18T10:37:36Z</dc:date>
    </item>
    <item>
      <title>Re: Merge SAS Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Merge-SAS-Dataset/m-p/292403#M8285</link>
      <description>&lt;P&gt;a) don't write code in capitals; causes eyesore&lt;/P&gt;
&lt;P&gt;b) use the "little running man" icon while composing a post to open a window for entering code; this makes example code more readable&lt;/P&gt;
&lt;P&gt;c) use proper indentation to make code more readable&lt;/P&gt;
&lt;P&gt;d) use the in= dataset option to create boolean variables that indicate when a dataset contributes to a merge or set:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have_a;
input ee_id prj_cd;
cards;
100055 406
100055 475
100055 492
300028 475
;
run;

data have_b;
input ee_id ssn emp_cd $;
cards;
100055 0100055 E
300028 0300028 E
;
run;

data want;
merge
  have_a (in=a)
  have_b (in=b)
;
by ee_id;
if a;
run;

proc print noobs;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The output from the above code looks like this:&lt;/P&gt;
&lt;PRE&gt; ee_id    prj_cd      ssn     emp_cd

100055      406     100055      E   
100055      475     100055      E   
100055      492     100055      E   
300028      475     300028      E   
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2016 10:47:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Merge-SAS-Dataset/m-p/292403#M8285</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2016-08-18T10:47:33Z</dc:date>
    </item>
    <item>
      <title>Re: Merge SAS Dataset</title>
      <link>https://communities.sas.com/t5/SAS-Data-Management/Merge-SAS-Dataset/m-p/292420#M8287</link>
      <description>&lt;P&gt;The result you are describing looks like what you would get if you played with the program many times in many ways, in an attempt to get it to work. &amp;nbsp;What actually happened somewhere along the way was that the variables SSN and EMP_CD got added to the data set A (somewhere along the way). &amp;nbsp;Then when you merge, those values get read in and overwrite the values from data set B. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;DROP the variables you don't need from the data set A. &amp;nbsp;That should take care of the problem.&lt;/P&gt;</description>
      <pubDate>Thu, 18 Aug 2016 12:15:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Data-Management/Merge-SAS-Dataset/m-p/292420#M8287</guid>
      <dc:creator>Astounding</dc:creator>
      <dc:date>2016-08-18T12:15:46Z</dc:date>
    </item>
  </channel>
</rss>

