<?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 Data set merge in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Data-set-merge/m-p/171870#M33060</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I am&amp;nbsp; trying to merge two data sets (something I have done 500 times). The field I am trying to add to the first from the second is not copying correctly in that the values are not matching correctly based on the 'by' variable. I have tried it several different ways and nothing seems to work. Anyone see anything? Its the AppearCount variable that I want to add and the values for it are not matching. Also the second data set (appearances2bt1) is actually a subset of the first.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Paul&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=appearances2b;&lt;BR /&gt;by docket_id;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc sort data=appearances2bt1;&lt;BR /&gt;by docket_id;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data AppearanceAttendDen;&lt;BR /&gt;length EventType $ 50;&lt;BR /&gt;merge appearances2b (in=a) appearances2bt1 (keep=docket_id AppearCount);&lt;BR /&gt;if a;&lt;BR /&gt;by docket_id;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;if event in ("AAD","AHR","ACT","AIQ","ANE","ANH","ACD","AHY","ASJ")&lt;BR /&gt;then EventType="Adjudication";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if event in ("DDD","DRR","DPP","DTP","DAJ","DSP","DDS","DOR",&lt;BR /&gt;"DWD") then EventType="Disposition";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if event in ("XCA","XRF","XRL","XGA","XAP","XRM","XOT") then EventType="Exit";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if event in ("PHR","PHC") then EventType="PermanencyHearing";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;drop AGEOUT IY NYC FCOUNT OCOUNT SCOUNT TCOUNT PCOUNT HCOUNT &lt;BR /&gt;DURCAT_ADJUD_DISPO1 DURCAT_ADJUD1 DUR_PL1 DURCAT_PL1 &lt;BR /&gt;PLACE_CAT1 TADJUD_FLAG CENSOR_TADJUD1 CENSOR_TADJUD1 DURCAT_TADJUD_TDISPO1 DURCAT_TADJUD_TDISPO1&lt;BR /&gt;durmod durmod_cat state link ageout count fcount_notpr place_end1 help durmoa durmoa_cat exit_pl1 stop_pl1&lt;BR /&gt;place1y;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 14 Nov 2014 12:15:03 GMT</pubDate>
    <dc:creator>Paul_NYS</dc:creator>
    <dc:date>2014-11-14T12:15:03Z</dc:date>
    <item>
      <title>Data set merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-set-merge/m-p/171870#M33060</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I am&amp;nbsp; trying to merge two data sets (something I have done 500 times). The field I am trying to add to the first from the second is not copying correctly in that the values are not matching correctly based on the 'by' variable. I have tried it several different ways and nothing seems to work. Anyone see anything? Its the AppearCount variable that I want to add and the values for it are not matching. Also the second data set (appearances2bt1) is actually a subset of the first.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Paul&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;proc sort data=appearances2b;&lt;BR /&gt;by docket_id;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;proc sort data=appearances2bt1;&lt;BR /&gt;by docket_id;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;data AppearanceAttendDen;&lt;BR /&gt;length EventType $ 50;&lt;BR /&gt;merge appearances2b (in=a) appearances2bt1 (keep=docket_id AppearCount);&lt;BR /&gt;if a;&lt;BR /&gt;by docket_id;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;if event in ("AAD","AHR","ACT","AIQ","ANE","ANH","ACD","AHY","ASJ")&lt;BR /&gt;then EventType="Adjudication";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if event in ("DDD","DRR","DPP","DTP","DAJ","DSP","DDS","DOR",&lt;BR /&gt;"DWD") then EventType="Disposition";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if event in ("XCA","XRF","XRL","XGA","XAP","XRM","XOT") then EventType="Exit";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if event in ("PHR","PHC") then EventType="PermanencyHearing";&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;drop AGEOUT IY NYC FCOUNT OCOUNT SCOUNT TCOUNT PCOUNT HCOUNT &lt;BR /&gt;DURCAT_ADJUD_DISPO1 DURCAT_ADJUD1 DUR_PL1 DURCAT_PL1 &lt;BR /&gt;PLACE_CAT1 TADJUD_FLAG CENSOR_TADJUD1 CENSOR_TADJUD1 DURCAT_TADJUD_TDISPO1 DURCAT_TADJUD_TDISPO1&lt;BR /&gt;durmod durmod_cat state link ageout count fcount_notpr place_end1 help durmoa durmoa_cat exit_pl1 stop_pl1&lt;BR /&gt;place1y;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Nov 2014 12:15:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-set-merge/m-p/171870#M33060</guid>
      <dc:creator>Paul_NYS</dc:creator>
      <dc:date>2014-11-14T12:15:03Z</dc:date>
    </item>
    <item>
      <title>Re: Data set merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-set-merge/m-p/171871#M33061</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you sure that you do not have an AppearCount in appearances2b already?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Nov 2014 12:53:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-set-merge/m-p/171871#M33061</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2014-11-14T12:53:49Z</dc:date>
    </item>
    <item>
      <title>Re: Data set merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-set-merge/m-p/171872#M33062</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Yes, KurtBremser has made the correct observation.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Tell us what you are really trying to do, because the two tables are equivalent.&amp;nbsp; They have the same number of rows, and both have the variables docket_id and AppearCount with the exact same values...unless you are doing some additional processing on appearances2bt1 that you have not shown. &lt;/P&gt;&lt;P&gt;Assuming the latter, just drop AppearCount from appearances2b and you should get what you are expecting.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Nov 2014 13:55:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-set-merge/m-p/171872#M33062</guid>
      <dc:creator>advoss</dc:creator>
      <dc:date>2014-11-14T13:55:41Z</dc:date>
    </item>
    <item>
      <title>Re: Data set merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Data-set-merge/m-p/171873#M33063</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I met your same problem with the merge statement,&lt;/P&gt;&lt;P&gt;In this post we talk about the merge statement in SAS:&lt;/P&gt;&lt;P&gt;&lt;A __default_attr="61576" __jive_macro_name="thread" class="jive_macro jive_macro_thread" href="https://communities.sas.com/"&gt;&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 14 Nov 2014 20:18:03 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Data-set-merge/m-p/171873#M33063</guid>
      <dc:creator>Rakeon</dc:creator>
      <dc:date>2014-11-14T20:18:03Z</dc:date>
    </item>
  </channel>
</rss>

