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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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