<?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 Using data from two datasets for an equation. in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Using-data-from-two-datasets-for-an-equation/m-p/237314#M55326</link>
    <description>&lt;P&gt;I have multiple different data sets, and I am trying to use two at a time for calculations. For instance:&lt;/P&gt;&lt;P&gt;I have a dataset with approximately 90,000 rows, each row has columns: policy , age, gender, loyalty (years with company), smoker, zip code, accidents, premium.&lt;/P&gt;&lt;P&gt;I have another dataset with 6 rows. each row has columns: accidents, Charge.&lt;/P&gt;&lt;P&gt;What I am trying to do is take the accidents from the first dataset for each row and reference that number of accidents with the same number in the second dataset under the accidents column, and then use what is in the charge column for that many accidents (by row) as a multiplier.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have spent a few hours trying different things and haven't really come up with any solutions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EDIT: I have uploaded a visual I quickly made to make it easier to understand what I am trying to accomplish&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/12110i65A7BF677275617E/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="visual.png" title="visual.png" /&gt;</description>
    <pubDate>Wed, 02 Dec 2015 04:57:49 GMT</pubDate>
    <dc:creator>preston</dc:creator>
    <dc:date>2015-12-02T04:57:49Z</dc:date>
    <item>
      <title>Using data from two datasets for an equation.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-data-from-two-datasets-for-an-equation/m-p/237314#M55326</link>
      <description>&lt;P&gt;I have multiple different data sets, and I am trying to use two at a time for calculations. For instance:&lt;/P&gt;&lt;P&gt;I have a dataset with approximately 90,000 rows, each row has columns: policy , age, gender, loyalty (years with company), smoker, zip code, accidents, premium.&lt;/P&gt;&lt;P&gt;I have another dataset with 6 rows. each row has columns: accidents, Charge.&lt;/P&gt;&lt;P&gt;What I am trying to do is take the accidents from the first dataset for each row and reference that number of accidents with the same number in the second dataset under the accidents column, and then use what is in the charge column for that many accidents (by row) as a multiplier.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have spent a few hours trying different things and haven't really come up with any solutions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EDIT: I have uploaded a visual I quickly made to make it easier to understand what I am trying to accomplish&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/12110i65A7BF677275617E/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="visual.png" title="visual.png" /&gt;</description>
      <pubDate>Wed, 02 Dec 2015 04:57:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-data-from-two-datasets-for-an-equation/m-p/237314#M55326</guid>
      <dc:creator>preston</dc:creator>
      <dc:date>2015-12-02T04:57:49Z</dc:date>
    </item>
    <item>
      <title>Re: Using data from two datasets for an equation.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-data-from-two-datasets-for-an-equation/m-p/237320#M55327</link>
      <description>This is a lookup, there are quite a few posts on here about the most efficient way. I suggest looking into proc format and a left join. &lt;BR /&gt;&lt;BR /&gt;Here's a paper that lists several other options:&lt;BR /&gt;&lt;A href="http://www2.sas.com/proceedings/forum2008/095-2008.pdf" target="_blank"&gt;http://www2.sas.com/proceedings/forum2008/095-2008.pdf&lt;/A&gt;</description>
      <pubDate>Wed, 02 Dec 2015 05:33:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-data-from-two-datasets-for-an-equation/m-p/237320#M55327</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2015-12-02T05:33:51Z</dc:date>
    </item>
    <item>
      <title>Re: Using data from two datasets for an equation.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-data-from-two-datasets-for-an-equation/m-p/237321#M55328</link>
      <description>I will look into that and read that link asap. thanks</description>
      <pubDate>Wed, 02 Dec 2015 05:35:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-data-from-two-datasets-for-an-equation/m-p/237321#M55328</guid>
      <dc:creator>preston</dc:creator>
      <dc:date>2015-12-02T05:35:54Z</dc:date>
    </item>
    <item>
      <title>Re: Using data from two datasets for an equation.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-data-from-two-datasets-for-an-equation/m-p/237327#M55330</link>
      <description>&lt;P&gt;I'm not having any luck with that info. All I can figure out how to do with a lookup is take an individual policy and perform my desired actions, I need to create a new table with every value from one dataset multiplied by its corresponding value from the other dataset&lt;/P&gt;</description>
      <pubDate>Wed, 02 Dec 2015 07:00:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-data-from-two-datasets-for-an-equation/m-p/237327#M55330</guid>
      <dc:creator>preston</dc:creator>
      <dc:date>2015-12-02T07:00:16Z</dc:date>
    </item>
    <item>
      <title>Re: Using data from two datasets for an equation.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-data-from-two-datasets-for-an-equation/m-p/237338#M55334</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc sql;
  create table WANT as
  select  A.*,
          B.CHARGE,
          A.ANNUAL_PREMIUM * CHARGE as NEW_PREMIUM
  from    WORK.HAVE A
  left join WORK.ACCIDENTS
  on      A.ACCIDENTS=B.ACCIDENTS;
quit;&lt;/PRE&gt;</description>
      <pubDate>Wed, 02 Dec 2015 09:40:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-data-from-two-datasets-for-an-equation/m-p/237338#M55334</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2015-12-02T09:40:18Z</dc:date>
    </item>
    <item>
      <title>Re: Using data from two datasets for an equation.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-data-from-two-datasets-for-an-equation/m-p/237343#M55336</link>
      <description>&lt;P&gt;Thanks, I'm going to bed now But I will work with this in the morning!&lt;/P&gt;</description>
      <pubDate>Wed, 02 Dec 2015 10:17:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-data-from-two-datasets-for-an-equation/m-p/237343#M55336</guid>
      <dc:creator>preston</dc:creator>
      <dc:date>2015-12-02T10:17:58Z</dc:date>
    </item>
    <item>
      <title>Re: Using data from two datasets for an equation.</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Using-data-from-two-datasets-for-an-equation/m-p/237391#M55344</link>
      <description>&lt;P&gt;data one;&lt;BR /&gt;input policy gender$ age loyalty smoker$ zipcode accidents annual_premium;&lt;BR /&gt;cards;&lt;BR /&gt;2 M 71 1 N 10468 0 1371.05&lt;BR /&gt;3 F 63 2 M 10500 1 865.34&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data two;&lt;BR /&gt;input accidents charge;&lt;BR /&gt;cards;&lt;BR /&gt;0 1&lt;BR /&gt;1 1.04&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt;&lt;BR /&gt;data want;&lt;BR /&gt;merge one (in=a)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; two (in=b);&lt;BR /&gt;by accidents;&lt;BR /&gt;if a and b;&lt;BR /&gt;new_premium = annual_premium*charge;&lt;BR /&gt;run;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Dec 2015 15:26:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Using-data-from-two-datasets-for-an-equation/m-p/237391#M55344</guid>
      <dc:creator>Steelers_In_DC</dc:creator>
      <dc:date>2015-12-02T15:26:12Z</dc:date>
    </item>
  </channel>
</rss>

