<?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 Creating weighted average in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/Creating-weighted-average/m-p/35722#M8853</link>
    <description>Hello&lt;BR /&gt;
&lt;BR /&gt;
I am trying to create the functionality of weighted average using SAS and need some help with the code.&lt;BR /&gt;
&lt;BR /&gt;
I have the following variables in my dataset arranged in the following order.&lt;BR /&gt;
&lt;BR /&gt;
Product - (Consumer)&lt;BR /&gt;
Rewards code - (Y or N)&lt;BR /&gt;
Risk type - (R1 to R5, Novalue)&lt;BR /&gt;
Relationship -(Full, medium, low)&lt;BR /&gt;
Number of accts&lt;BR /&gt;
dollarprofit&lt;BR /&gt;
&lt;BR /&gt;
For Risktype = Novalue and Relationship type = Full&lt;BR /&gt;
&lt;BR /&gt;
I am trying to compute the weighted average as &lt;BR /&gt;
=(Dollerprofit(of R1-Full)*numberofaccts(of R1-Full)+&lt;BR /&gt;
  Dollerprofit(of R2-Full)*numberofaccts(of R2-Full)+&lt;BR /&gt;
 Dollerprofit(of R3-Full)*numberofaccts(of R3-Full)+&lt;BR /&gt;
 Dollerprofit(of R4-Full)*numberofaccts(of R4-Full)+&lt;BR /&gt;
 Dollerprofit(of R5-Full)*numberofaccts(of R5-Full))/&lt;BR /&gt;
 sum[numberofaccts(of R1-Full)+  numberofaccts(of R2-Full)+&lt;BR /&gt;
 numberofaccts(of R3-Full)+ numberofaccts(of R4-Full)+&lt;BR /&gt;
 numberofaccts(of R5-Full))&lt;BR /&gt;
&lt;BR /&gt;
The similar needs to be achieved for &lt;BR /&gt;
Risktype = Novalue and Relationship type = medium&lt;BR /&gt;
Risktype = Novalue and Relationship type = low&lt;BR /&gt;
&lt;BR /&gt;
and needs to be done for all Rewards = Yes and No.&lt;BR /&gt;
&lt;BR /&gt;
Could anyone tell me how to achieve this using SAS&lt;BR /&gt;
&lt;BR /&gt;
Thanks</description>
    <pubDate>Tue, 15 Jun 2010 14:41:23 GMT</pubDate>
    <dc:creator>deleted_user</dc:creator>
    <dc:date>2010-06-15T14:41:23Z</dc:date>
    <item>
      <title>Creating weighted average</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-weighted-average/m-p/35722#M8853</link>
      <description>Hello&lt;BR /&gt;
&lt;BR /&gt;
I am trying to create the functionality of weighted average using SAS and need some help with the code.&lt;BR /&gt;
&lt;BR /&gt;
I have the following variables in my dataset arranged in the following order.&lt;BR /&gt;
&lt;BR /&gt;
Product - (Consumer)&lt;BR /&gt;
Rewards code - (Y or N)&lt;BR /&gt;
Risk type - (R1 to R5, Novalue)&lt;BR /&gt;
Relationship -(Full, medium, low)&lt;BR /&gt;
Number of accts&lt;BR /&gt;
dollarprofit&lt;BR /&gt;
&lt;BR /&gt;
For Risktype = Novalue and Relationship type = Full&lt;BR /&gt;
&lt;BR /&gt;
I am trying to compute the weighted average as &lt;BR /&gt;
=(Dollerprofit(of R1-Full)*numberofaccts(of R1-Full)+&lt;BR /&gt;
  Dollerprofit(of R2-Full)*numberofaccts(of R2-Full)+&lt;BR /&gt;
 Dollerprofit(of R3-Full)*numberofaccts(of R3-Full)+&lt;BR /&gt;
 Dollerprofit(of R4-Full)*numberofaccts(of R4-Full)+&lt;BR /&gt;
 Dollerprofit(of R5-Full)*numberofaccts(of R5-Full))/&lt;BR /&gt;
 sum[numberofaccts(of R1-Full)+  numberofaccts(of R2-Full)+&lt;BR /&gt;
 numberofaccts(of R3-Full)+ numberofaccts(of R4-Full)+&lt;BR /&gt;
 numberofaccts(of R5-Full))&lt;BR /&gt;
&lt;BR /&gt;
The similar needs to be achieved for &lt;BR /&gt;
Risktype = Novalue and Relationship type = medium&lt;BR /&gt;
Risktype = Novalue and Relationship type = low&lt;BR /&gt;
&lt;BR /&gt;
and needs to be done for all Rewards = Yes and No.&lt;BR /&gt;
&lt;BR /&gt;
Could anyone tell me how to achieve this using SAS&lt;BR /&gt;
&lt;BR /&gt;
Thanks</description>
      <pubDate>Tue, 15 Jun 2010 14:41:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-weighted-average/m-p/35722#M8853</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-06-15T14:41:23Z</dc:date>
    </item>
    <item>
      <title>Re: Creating weighted average</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-weighted-average/m-p/35723#M8854</link>
      <description>I suggest you investigate the MEANS procedure. The combination of the MEAN statistic with the WEIGHT statement will do a weighted average. If I understand your description correctly it appears you are weighting by the number of accounts.&lt;BR /&gt;
&lt;BR /&gt;
Your skeleton code will probably look like something like this:&lt;BR /&gt;
&lt;BR /&gt;
proc means data = xxx nway;&lt;BR /&gt;
  where risk type in R1 to R5;&lt;BR /&gt;
  class relationship;&lt;BR /&gt;
  var dollarprofit;&lt;BR /&gt;
  weight Number of accts;&lt;BR /&gt;
  output out = xxx_out&lt;BR /&gt;
            mean = &lt;BR /&gt;
           ;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
You can also do weighted averages in the REPORT procedure but the learning curve is much higher.</description>
      <pubDate>Wed, 16 Jun 2010 01:38:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-weighted-average/m-p/35723#M8854</guid>
      <dc:creator>SASKiwi</dc:creator>
      <dc:date>2010-06-16T01:38:12Z</dc:date>
    </item>
    <item>
      <title>Re: Creating weighted average</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/Creating-weighted-average/m-p/35724#M8855</link>
      <description>Thank you this works. Appreciate it.</description>
      <pubDate>Wed, 16 Jun 2010 18:44:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/Creating-weighted-average/m-p/35724#M8855</guid>
      <dc:creator>deleted_user</dc:creator>
      <dc:date>2010-06-16T18:44:58Z</dc:date>
    </item>
  </channel>
</rss>

