BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Waqar
Calcite | Level 5

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.

Thanks in advance.

Regards,

Waqar

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

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

View solution in original post

1 REPLY 1
PGStats
Opal | Level 21

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

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 730 views
  • 0 likes
  • 2 in conversation