<?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: Help with a Merge in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Help-with-a-Merge/m-p/409279#M279541</link>
    <description>This is much easier if you provide sample data we can work with. But the concept is still the same, calculate a summary statistic and merge in with the full data. You may be able to do this summarizing the accident data to determine the number of distracted drivers per accident and then merging that summary data.</description>
    <pubDate>Tue, 31 Oct 2017 20:17:57 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2017-10-31T20:17:57Z</dc:date>
    <item>
      <title>Help with a Merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-a-Merge/m-p/409277#M279540</link>
      <description>&lt;P&gt;I am looking for help with how to do what I believe is a many - to - one merge (if possible).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have 2 data sets :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;A.&amp;nbsp;car crashes (each observation is a crash)&lt;/P&gt;&lt;P&gt;B.&amp;nbsp;car vehicles involved in&amp;nbsp;a crash (each observation is a car in one of the crashes in first data set)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have an indicator called "distract"&amp;nbsp;in data set B that determines whether the driver of that car was distracted while driving.&lt;/P&gt;&lt;P&gt;0 = not distracted&lt;/P&gt;&lt;P&gt;1 = distracted&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want a merge into data set&amp;nbsp;A so that that&amp;nbsp;the crash takes&amp;nbsp;on the value of &amp;nbsp;1 if ANY of the cars involved in that crash&amp;nbsp;had a distracted driver. &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another way that could be acceptable, is the "distract" variable in the new merged set can take on the value of the SUM of distracted drivers involved in the crash.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;in case you need to know, they are merging by caseid year psu .&lt;/P&gt;</description>
      <pubDate>Tue, 31 Oct 2017 20:11:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-a-Merge/m-p/409277#M279540</guid>
      <dc:creator>UCFtigers2017</dc:creator>
      <dc:date>2017-10-31T20:11:09Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a Merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-a-Merge/m-p/409279#M279541</link>
      <description>This is much easier if you provide sample data we can work with. But the concept is still the same, calculate a summary statistic and merge in with the full data. You may be able to do this summarizing the accident data to determine the number of distracted drivers per accident and then merging that summary data.</description>
      <pubDate>Tue, 31 Oct 2017 20:17:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-a-Merge/m-p/409279#M279541</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2017-10-31T20:17:57Z</dc:date>
    </item>
    <item>
      <title>Re: Help with a Merge</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Help-with-a-Merge/m-p/409310#M279542</link>
      <description>&lt;P&gt;Maybe something similar to:&lt;/P&gt;
&lt;PRE&gt;proc sql;
   create table want as
   select a.*, max(b.distracted) as AnyDistracted,
          sum(b.Distracted) as TotalDistracted
   from crashset as a
        left join
        vehicleset a b
        on a.caseid=b.caseid
        and a.year =b.year
        and a.psu  =b.psu
  group by a.crashid,a.year,a.psu
  ;
quit; &lt;/PRE&gt;</description>
      <pubDate>Tue, 31 Oct 2017 22:52:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Help-with-a-Merge/m-p/409310#M279542</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-10-31T22:52:54Z</dc:date>
    </item>
  </channel>
</rss>

