BookmarkSubscribeRSS Feed
Denali
Quartz | Level 8

I have 15 continuous variables and the data entry person defined "888" and "999" as missing. I don;t want these two numbers to be calculated in the proc means procedure as they appeared to be the maximum values. Is there a way to recode 888 and 999 as . ?

 

Could you please coach me how to do the data cleaning step in the data step? Thank you!

 

Attached is the data and below are the variables I was using. 

 

%macro one(x) (where=(wrat_raw not in (888 999)));
proc means n mean std median min max maxdec=1;
var &x;
class site_id Phase visit_id;
run;
%mend one;
%one (wrat_raw);
%one (wrat_ss);
%one (wrat_perc);

%one (bacs_symbol_raw);
%one (bacs_standardized);
%one (bacs_percentile);

%one (hvlt_trial1);
%one (hvlt_trial2);
%one (hvlt_trial3);
%one (hvlttot);
%one (hvlt_standardized);
%one (hvlt_percentile);

%one (msceit_raw);
%one (msceit);
%one (msceitpercentile);

 

1 REPLY 1
Astounding
PROC Star

You can recode them in a DATA step easily enough.  But I would suggest using special missing values, rather than . so here is an example using 3 variables:

 

data want;

set have;

array nums {*} wrat_raw wrat_ss wrat_perc;

do k=1 to dim(nums);

   if nums{k} = 888 then nums{k} = .A;

   else if nums{k}= 999 then nums{k} = .B;

end;

drop k;

run;

 

The special missing values will automatically be excluded from PROC MEANS calculations.  But you still have a record of what the value used to be, if that ever becomes important to know.

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
  • 1660 views
  • 6 likes
  • 2 in conversation