<?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: Imputing numbers based on the frequency distribution in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Imputing-numbers-based-on-the-frequency-distribution/m-p/640138#M190592</link>
    <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input n id1name $ idname $; 
cards;
0 D Buk 
4 D Dalseo 
1 D Dalseong 
1 D Dong 
3 D Jung 
8 D Nam 
2 D Seo 
2 D Suseong
5 C Hart
6 C Sous
; 



data new_values;
input id1name $ newBase;
cards;
D 120
C 50
;;;
run;

proc sort data=have;
by id1name;
run;

proc sort data=new_values;
by id1name;
run;

proc freq data=have noprint;
by id1name;
table idname / out=percents;
weight n;
run;

data want;
merge percents new_values;
by id1name;
newValue = round(newBase*percent/100, 1);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 15 Apr 2020 16:51:29 GMT</pubDate>
    <dc:creator>Reeza</dc:creator>
    <dc:date>2020-04-15T16:51:29Z</dc:date>
    <item>
      <title>Imputing numbers based on the frequency distribution</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Imputing-numbers-based-on-the-frequency-distribution/m-p/640119#M190580</link>
      <description>&lt;P&gt;Hi Folks:&lt;/P&gt;
&lt;P&gt;I'd like to impute data where id1name='D'. I'd like to bring current n=21 to a total of&amp;nbsp; n =120 keeping the frequency distribution of n by idname. I tried&amp;nbsp;it manually by using proc freq on the 'n' and multipling 120 by the resulting percent from proc freq and allocated those numbers to idname. I will have to do the same thing for the rest of id1name such as 'C' too.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Could you please help accomplish this imputation task more efficiently than manual?&amp;nbsp; &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input n id1name $ idname $; 
cards;
0 D Buk 
4 D Dalseo 
1 D Dalseong 
1 D Dong 
3 D Jung 
8 D Nam 
2 D Seo 
2 D Suseong
5 C Hart
6 C Sous
; &lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Apr 2020 14:52:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Imputing-numbers-based-on-the-frequency-distribution/m-p/640119#M190580</guid>
      <dc:creator>Cruise</dc:creator>
      <dc:date>2020-04-15T14:52:12Z</dc:date>
    </item>
    <item>
      <title>Re: Imputing numbers based on the frequency distribution</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Imputing-numbers-based-on-the-frequency-distribution/m-p/640138#M190592</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
input n id1name $ idname $; 
cards;
0 D Buk 
4 D Dalseo 
1 D Dalseong 
1 D Dong 
3 D Jung 
8 D Nam 
2 D Seo 
2 D Suseong
5 C Hart
6 C Sous
; 



data new_values;
input id1name $ newBase;
cards;
D 120
C 50
;;;
run;

proc sort data=have;
by id1name;
run;

proc sort data=new_values;
by id1name;
run;

proc freq data=have noprint;
by id1name;
table idname / out=percents;
weight n;
run;

data want;
merge percents new_values;
by id1name;
newValue = round(newBase*percent/100, 1);
run;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 15 Apr 2020 16:51:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Imputing-numbers-based-on-the-frequency-distribution/m-p/640138#M190592</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-04-15T16:51:29Z</dc:date>
    </item>
  </channel>
</rss>

