Hi! I'm a little confused about the question below and not sure how to code it. Any input is greatly appreciated. Thank you!
A sas dataset has the following values for its 35 numeric variables:
99 Do not know
98 Refused to answer
97 Skipped question
Write the data step statement to convert these values to the standard sas missing value (.)
@Amy0223 wrote:
Hi! I'm a little confused about the question below and not sure how to code it. Any input is greatly appreciated. Thank you!
A sas dataset has the following values for its 35 numeric variables:
99 Do not know
98 Refused to answer
97 Skipped question
Write the data step statement to convert these values to the standard sas missing value (.)
Here's an example you can run based on the CLASS data set. I prefer to use CALL MISSING to set values to missing because it works the same for numeric and character variables.
Depending on what you've been studying so far, if this is homework, you may need to use the approach taught in class rather than what I've posted.
data example;
set sashelp.class;
if age in (12, 13, 14) then call missing(age);
*if age=12 or age=13 or age=14 then age = . ;
run;
Does this answer look right? I'm not sure what I need to do with 35 numeric variables.
Data zz; input x response $18.; cards; 99 Do not know 98 Refused to answer 97 Skipped question ; run; proc print; run; data zz1; set zz; if x in (99, 98, 97) then call missing(x); run; proc print; run;
A good way to do the same thing for more than one variable is to use an array. Did you learn how to use an array?
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.