## windorize without replacing missing data

Solved
Occasional Contributor
Posts: 8

# windorize without replacing missing data

Hi

I need to windorize data. I am using the following code to do so. However, it replaces the missing values too.

proc univariate data=acc_data noprint;

var cash CF Lev Q DVC AT B2M LagAT;

output out=_winsor   pctlpts=1 99     pctlpre=__cash __CF __Lev __Q __DVC __AT __B2M __LagAT;

run;

data acc_data_win (drop=_;

set acc_data;

if _n_=1 then set _winsor;

array wlo  {*} __cash1 __CF1 __Lev1 __Q1 __DVC1 __AT1 __B2M1 __LagAT1;

array whi  {*} __cash99 __CF99 __Lev99 __Q99 __DVC99 __AT99 __B2M99 __LagAT99;

array wval {*} wcash wCF wLev wQ wDVC wAT wB2M wLagAT;

array val   {*} cash CF Lev Q DVC AT B2M LagAT;

do _V=1 to dim(val);

end;

run;

Any suggestion to avoid replacing missing values and windorize only the non missing values.

Regards,

Waqar

Accepted Solutions
Solution
‎06-19-2013 10:53 AM
Posts: 5,526

## Re: windorize without replacing missing data

To avoid replacing missing values, you must exclude missing values from the lower range (they rank as minus infinity) :

do _V=1 to dim(val);

if . < val{_V} < wlo{_V} then val{_V} = wlo{_V};

else if val{_V} > whi{_V} then val{_V} = whi{_V};

end;

you might need a retain statement on the _winsor variables.

PG

PG

All Replies
Solution
‎06-19-2013 10:53 AM
Posts: 5,526

## Re: windorize without replacing missing data

To avoid replacing missing values, you must exclude missing values from the lower range (they rank as minus infinity) :

do _V=1 to dim(val);

if . < val{_V} < wlo{_V} then val{_V} = wlo{_V};

else if val{_V} > whi{_V} then val{_V} = whi{_V};

end;

you might need a retain statement on the _winsor variables.

PG

PG
🔒 This topic is solved and locked.