Date: Mon, 21 Dec 2009 01:13:22 -0800
Reply-To: "Eli Y. Kling" <eli.kling@GMAIL.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Eli Y. Kling" <eli.kling@GMAIL.COM>
Organization: http://groups.google.com
Subject: Re: Replace Missing Values withing Medians from each sub-groups
Content-Type: text/plain; charset=ISO-8859-1
Try this:
data DB;
input CountryCode $ COMPANYAGE;
datalines;
UK 10
UK .
UK 12
FR 10
FR .
US 20
US .
US 10
;
run;
proc univariate data=DB;
var CompanyAge ;
class CountryCode;
output out=decile_CompanyAge_ pctlpts=50 pctlpre=CompanyAge_;
run;quit;
proc sort data=db; by CountryCode; run;
proc sort data=decile_CompanyAge_; by CountryCode; run;
data DB1;
merge DB decile_CompanyAge_;
by CountryCode;
if missing(CompanyAge) then do;
CompanyAge=CompanyAge_50;
Imputed=1;
end;
else Imputed=0;
run;
|