<?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: Ratio of values based on another dataset in New SAS User</title>
    <link>https://communities.sas.com/t5/New-SAS-User/Ratio-of-values-based-on-another-dataset/m-p/891343#M39648</link>
    <description>Sorry, you are right. I edited the post</description>
    <pubDate>Mon, 28 Aug 2023 15:49:01 GMT</pubDate>
    <dc:creator>NewUsrStat</dc:creator>
    <dc:date>2023-08-28T15:49:01Z</dc:date>
    <item>
      <title>Ratio of values based on another dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Ratio-of-values-based-on-another-dataset/m-p/891324#M39643</link>
      <description>&lt;P&gt;Hi guys,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;suppose to have the following table:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;dataset 1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 144pt;" border="0" width="192" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD width="64" height="19" class="xl63" style="height: 14.5pt; width: 48pt;"&gt;Region&lt;/TD&gt;
&lt;TD width="64" class="xl63" style="width: 48pt;"&gt;Value&lt;/TD&gt;
&lt;TD width="64" class="xl63" style="width: 48pt;"&gt;Class&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD height="19" class="xl63" style="height: 14.5pt;"&gt;1&lt;/TD&gt;
&lt;TD class="xl63"&gt;34&lt;/TD&gt;
&lt;TD class="xl63"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD height="19" class="xl63" style="height: 14.5pt;"&gt;2&lt;/TD&gt;
&lt;TD class="xl63"&gt;23&lt;/TD&gt;
&lt;TD class="xl63"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD height="19" class="xl63" style="height: 14.5pt;"&gt;3&lt;/TD&gt;
&lt;TD class="xl63"&gt;12&lt;/TD&gt;
&lt;TD class="xl63"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD height="19" class="xl63" style="height: 14.5pt;"&gt;1&lt;/TD&gt;
&lt;TD class="xl63"&gt;65&lt;/TD&gt;
&lt;TD class="xl63"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD height="19" class="xl63" style="height: 14.5pt;"&gt;2&lt;/TD&gt;
&lt;TD class="xl63"&gt;32&lt;/TD&gt;
&lt;TD class="xl63"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD height="19" class="xl63" style="height: 14.5pt;"&gt;3&lt;/TD&gt;
&lt;TD class="xl63"&gt;43&lt;/TD&gt;
&lt;TD class="xl63"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD height="19" class="xl63" style="height: 14.5pt;"&gt;1&lt;/TD&gt;
&lt;TD class="xl63"&gt;98&lt;/TD&gt;
&lt;TD class="xl63"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD height="19" class="xl63" style="height: 14.5pt;"&gt;2&lt;/TD&gt;
&lt;TD class="xl63"&gt;76&lt;/TD&gt;
&lt;TD class="xl63"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD height="19" class="xl63" style="height: 14.5pt;"&gt;3&lt;/TD&gt;
&lt;TD class="xl63"&gt;44&lt;/TD&gt;
&lt;TD class="xl63"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD height="19" class="xl63" style="height: 14.5pt;"&gt;1&lt;/TD&gt;
&lt;TD class="xl63"&gt;1&lt;/TD&gt;
&lt;TD class="xl63"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD height="19" class="xl63" style="height: 14.5pt;"&gt;2&lt;/TD&gt;
&lt;TD class="xl63"&gt;2&lt;/TD&gt;
&lt;TD class="xl63"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD height="19" class="xl63" style="height: 14.5pt;"&gt;3&lt;/TD&gt;
&lt;TD class="xl63"&gt;3&lt;/TD&gt;
&lt;TD class="xl63"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD height="19" class="xl63" style="height: 14.5pt;"&gt;1&lt;/TD&gt;
&lt;TD class="xl63"&gt;45&lt;/TD&gt;
&lt;TD class="xl63"&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD height="19" class="xl63" style="height: 14.5pt;"&gt;2&lt;/TD&gt;
&lt;TD class="xl63"&gt;38&lt;/TD&gt;
&lt;TD class="xl63"&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD height="19" class="xl63" style="height: 14.5pt;"&gt;3&lt;/TD&gt;
&lt;TD class="xl63"&gt;43&lt;/TD&gt;
&lt;TD class="xl63"&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD height="19" class="xl63" style="height: 14.5pt;"&gt;1&lt;/TD&gt;
&lt;TD class="xl63"&gt;0&lt;/TD&gt;
&lt;TD class="xl63"&gt;5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD height="19" class="xl63" style="height: 14.5pt;"&gt;2&lt;/TD&gt;
&lt;TD class="xl63"&gt;0&lt;/TD&gt;
&lt;TD class="xl63"&gt;5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD height="19" class="xl63" style="height: 14.5pt;"&gt;3&lt;/TD&gt;
&lt;TD class="xl63"&gt;0&lt;/TD&gt;
&lt;TD class="xl63"&gt;5&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&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;
&lt;LI-CODE lang="sas"&gt;data dataset1;
  input Region Value Class $;
cards;
1 34 0
2 23 0
3 12 0
1 65 1
2 32 1
3 43 1
1 98 2
2 76 2
3 44 2
1 1 3
2 2 3
3 3 3
1 45 4
2 38 4
3 43 4
;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you have another dataset as follows:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;dataset 2&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 96pt;" border="0" width="127px" cellspacing="0" cellpadding="0"&gt;
&lt;TBODY&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD width="63.4271px" height="19" class="xl65" style="height: 14.5pt; width: 48pt;"&gt;ID&lt;/TD&gt;
&lt;TD width="63.9062px" class="xl65" style="width: 48pt;"&gt;Region&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD width="63.4271px" height="19" align="right" style="height: 14.5pt;"&gt;1&lt;/TD&gt;
&lt;TD width="63.9062px" class="xl65"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD width="63.4271px" height="19" align="right" style="height: 14.5pt;"&gt;2&lt;/TD&gt;
&lt;TD width="63.9062px" class="xl65"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD width="63.4271px" height="19" align="right" style="height: 14.5pt;"&gt;3&lt;/TD&gt;
&lt;TD width="63.9062px" class="xl65"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD width="63.4271px" height="19" align="right" style="height: 14.5pt;"&gt;4&lt;/TD&gt;
&lt;TD width="63.9062px" class="xl65"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD width="63.4271px" height="19" align="right" style="height: 14.5pt;"&gt;5&lt;/TD&gt;
&lt;TD width="63.9062px" class="xl65"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD width="63.4271px" height="19" align="right" style="height: 14.5pt;"&gt;6&lt;/TD&gt;
&lt;TD width="63.9062px" class="xl65"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD width="63.4271px" height="19" align="right" style="height: 14.5pt;"&gt;7&lt;/TD&gt;
&lt;TD width="63.9062px" class="xl65"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD width="63.4271px" height="19" align="right" style="height: 14.5pt;"&gt;8&lt;/TD&gt;
&lt;TD width="63.9062px" class="xl65"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD width="63.4271px" height="19" align="right" style="height: 14.5pt;"&gt;9&lt;/TD&gt;
&lt;TD width="63.9062px" class="xl65"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD width="63.4271px" height="19" align="right" style="height: 14.5pt;"&gt;10&lt;/TD&gt;
&lt;TD width="63.9062px" class="xl65"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD width="63.4271px" height="19" align="right" style="height: 14.5pt;"&gt;11&lt;/TD&gt;
&lt;TD width="63.9062px" class="xl65"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD width="63.4271px" height="19" align="right" style="height: 14.5pt;"&gt;12&lt;/TD&gt;
&lt;TD width="63.9062px" class="xl65"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD width="63.4271px" height="19" align="right" style="height: 14.5pt;"&gt;13&lt;/TD&gt;
&lt;TD width="63.9062px" class="xl65"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD width="63.4271px" height="19" align="right" style="height: 14.5pt;"&gt;14&lt;/TD&gt;
&lt;TD width="63.9062px" class="xl65"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD width="63.4271px" height="19" align="right" style="height: 14.5pt;"&gt;15&lt;/TD&gt;
&lt;TD width="63.9062px" class="xl65"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD width="63.4271px" height="19" align="right" style="height: 14.5pt;"&gt;16&lt;/TD&gt;
&lt;TD width="63.9062px" class="xl65"&gt;1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD width="63.4271px" height="19" align="right" style="height: 14.5pt;"&gt;17&lt;/TD&gt;
&lt;TD width="63.9062px" class="xl65"&gt;2&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.5pt;"&gt;
&lt;TD width="63.4271px" height="19" align="right" style="height: 14.5pt;"&gt;18&lt;/TD&gt;
&lt;TD width="63.9062px" class="xl65"&gt;3&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;data dataset2;
  input ID Region $;
cards;
1  1
2  1
3  3
4  2 
5  2
6  3
7  1
8  2
9  1
10 1
11 1
12 3
13 3
14 3
15 2
16 1
17 2
18 3
;&lt;/LI-CODE&gt;
&lt;P&gt;Then you want to divide each value of the column "Value" of the first dataset by the total number of corresponding "Region" class in the second dataset. Lets say: 34 will be divided by 7 because in dataset 2 there are 7 IDs from region = 1.&amp;nbsp; 23 in dataset 1 will be divided by 5 because there are 5 IDs in dataset 2 with "Region" = 2. This, will be done in dataset 1 regardless of the "Class" variable. It will be there and will not take any part into the calculation. Can anyone help me please?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you in advance&lt;/P&gt;</description>
      <pubDate>Mon, 28 Aug 2023 15:48:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Ratio-of-values-based-on-another-dataset/m-p/891324#M39643</guid>
      <dc:creator>NewUsrStat</dc:creator>
      <dc:date>2023-08-28T15:48:35Z</dc:date>
    </item>
    <item>
      <title>Re: Ratio of values based on another dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Ratio-of-values-based-on-another-dataset/m-p/891327#M39644</link>
      <description>&lt;P&gt;OK - first things first:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How do you propose to get the frequency of REGION in dataset 2?&amp;nbsp; There are many ways, but I suggest taking a look at PROC FREQ and the OUT option of the TABLE statement.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Once you have done that, then you can consider accessing those frequencies while processing dataset 1.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Aug 2023 14:04:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Ratio-of-values-based-on-another-dataset/m-p/891327#M39644</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2023-08-28T14:04:33Z</dc:date>
    </item>
    <item>
      <title>Re: Ratio of values based on another dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Ratio-of-values-based-on-another-dataset/m-p/891331#M39646</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/134532"&gt;@NewUsrStat&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I &lt;A href="https://communities.sas.com/t5/New-SAS-User/Perform-a-ratio-by-classes/m-p/891240" target="_self"&gt;previously helped you&lt;/A&gt;, and requested that in all future threads, you provide data as working SAS data step code, and I provided a simple example. Please do that. We're trying to help you, but you have to help us too.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Aug 2023 14:52:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Ratio-of-values-based-on-another-dataset/m-p/891331#M39646</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2023-08-28T14:52:11Z</dc:date>
    </item>
    <item>
      <title>Re: Ratio of values based on another dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Ratio-of-values-based-on-another-dataset/m-p/891343#M39648</link>
      <description>Sorry, you are right. I edited the post</description>
      <pubDate>Mon, 28 Aug 2023 15:49:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Ratio-of-values-based-on-another-dataset/m-p/891343#M39648</guid>
      <dc:creator>NewUsrStat</dc:creator>
      <dc:date>2023-08-28T15:49:01Z</dc:date>
    </item>
    <item>
      <title>Re: Ratio of values based on another dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Ratio-of-values-based-on-another-dataset/m-p/891394#M39649</link>
      <description>Thank you mkeintz. Yes, the idea is to use proc freq but I would like to do all in the same piece of code, let say do the ratio while calculating the "unverses" in dataset2</description>
      <pubDate>Mon, 28 Aug 2023 19:48:13 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Ratio-of-values-based-on-another-dataset/m-p/891394#M39649</guid>
      <dc:creator>NewUsrStat</dc:creator>
      <dc:date>2023-08-28T19:48:13Z</dc:date>
    </item>
    <item>
      <title>Re: Ratio of values based on another dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Ratio-of-values-based-on-another-dataset/m-p/891398#M39650</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/134532"&gt;@NewUsrStat&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;Thank you mkeintz. Yes, the idea is to use proc freq but I would like to do all in the same piece of code, let say do the ratio while calculating the "unverses" in dataset2&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;By "same piece of code" do you mean a single data or proc step?&amp;nbsp; Or just a PROC followed by another proc or data step in a single program?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Oh yes,&amp;nbsp; and why do you define REGION as a numberic variable in one dataset and character in the other?&amp;nbsp; How do you expect to match the needed counts for character-variable REGION in dataset2 with numeric REGION in dataset1?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Make yourself the master of this task, not the other way around.&amp;nbsp; That starts with clearly and comprehensively stating the problem, with vetted sample data.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Aug 2023 20:44:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Ratio-of-values-based-on-another-dataset/m-p/891398#M39650</guid>
      <dc:creator>mkeintz</dc:creator>
      <dc:date>2023-08-28T20:44:46Z</dc:date>
    </item>
    <item>
      <title>Re: Ratio of values based on another dataset</title>
      <link>https://communities.sas.com/t5/New-SAS-User/Ratio-of-values-based-on-another-dataset/m-p/891400#M39651</link>
      <description>ok I've got it.</description>
      <pubDate>Mon, 28 Aug 2023 20:50:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/New-SAS-User/Ratio-of-values-based-on-another-dataset/m-p/891400#M39651</guid>
      <dc:creator>NewUsrStat</dc:creator>
      <dc:date>2023-08-28T20:50:44Z</dc:date>
    </item>
  </channel>
</rss>

