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.

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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