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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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