<?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: Rim weighting in sas in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Rim-weighting-in-sas/m-p/391192#M277650</link>
    <description>&lt;P&gt;Hi Snoopy&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;RAKINGE is the macro i am interested but i cant understand where to enter the target weights and update the macro to run for age and gender .....can you please share a working e.g. for the same on a random data set similar to what i have explained earlier.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;your&amp;nbsp;guidance&amp;nbsp;would be really helpful.&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 28 Aug 2017 06:44:52 GMT</pubDate>
    <dc:creator>Bedi</dc:creator>
    <dc:date>2017-08-28T06:44:52Z</dc:date>
    <item>
      <title>Rim weighting in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rim-weighting-in-sas/m-p/390881#M277648</link>
      <description>&lt;P&gt;Hi I have a sas data set of FMCG sector with below demographics &amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Males &lt;/STRONG&gt;45%&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Females &lt;/STRONG&gt;55%&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Age group 18-35 &amp;nbsp;&lt;/STRONG&gt;48%&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Age group 35-55+ &lt;/STRONG&gt;52%&lt;/P&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;P&gt;now the client wants me to calculate weighting factor for every respondent in the data so as to get below demographics percentage&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Males&lt;/STRONG&gt; 50%&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Females&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;50%&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Age group 18-35 &amp;nbsp;&lt;/STRONG&gt;30%&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Age group&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;35-55+&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;70%&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If i calculate this through rim weights a respondents whould have weight factors as per below is&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;male - age 18-35 ---&amp;gt;&amp;nbsp;0.69444&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;male - age 35-35+&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;---&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;1.495&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;female - age 18-35&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;---&amp;gt;&amp;nbsp;0.568&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;female - age&amp;nbsp;35-35+&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;---&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;1.223&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Can i calculate such weight factors through SAS, where i can supply the expected precentages and get weight factors?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 25 Aug 2017 12:11:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rim-weighting-in-sas/m-p/390881#M277648</guid>
      <dc:creator>Bedi</dc:creator>
      <dc:date>2017-08-25T12:11:04Z</dc:date>
    </item>
    <item>
      <title>Re: Rim weighting in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rim-weighting-in-sas/m-p/390982#M277649</link>
      <description>&lt;P&gt;You can trivially calculate them by&amp;nbsp;doing a PROC FREQ, then merge them back to the&amp;nbsp;main table along with the targets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
  call streaminit(7);
  do _n_=1 to 2000;
     if rand('uniform')&amp;lt;=.48 then age='18-35';    
     else age='35+';
     if rand('uniform')&amp;lt;=.45 then sex='M  '; 
     else sex='F';
     output;
  end;
run;

proc freq data=have;
  tables age*sex/out=age_sex_totals;
run;

data targets;
length age $5 sex $1;
input age $ sex $ target;
datalines;
18-35 F .15
18-35 M .15
35+   F .35
35+   M .35
;;;;
run;

proc sort data=targets;
by age sex;
run;

data want_wts;
  merge age_sex_totals targets;
  by age sex;
  weight = 100*target/percent;
run;

proc sort data=have;
  by age sex;
run;

data want;
  merge have want_wts;
  by age sex;
run;

proc freq data=want;
  weight weight;
  tables age*sex;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For more complicated cases, there are macros online (RAKINGE is the one I typically use).&lt;/P&gt;</description>
      <pubDate>Fri, 25 Aug 2017 17:23:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rim-weighting-in-sas/m-p/390982#M277649</guid>
      <dc:creator>snoopy369</dc:creator>
      <dc:date>2017-08-25T17:23:41Z</dc:date>
    </item>
    <item>
      <title>Re: Rim weighting in sas</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Rim-weighting-in-sas/m-p/391192#M277650</link>
      <description>&lt;P&gt;Hi Snoopy&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;RAKINGE is the macro i am interested but i cant understand where to enter the target weights and update the macro to run for age and gender .....can you please share a working e.g. for the same on a random data set similar to what i have explained earlier.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;your&amp;nbsp;guidance&amp;nbsp;would be really helpful.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Aug 2017 06:44:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Rim-weighting-in-sas/m-p/391192#M277650</guid>
      <dc:creator>Bedi</dc:creator>
      <dc:date>2017-08-28T06:44:52Z</dc:date>
    </item>
  </channel>
</rss>

