BookmarkSubscribeRSS Feed
Amy0223
Quartz | Level 8

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 (.)

5 REPLIES 5
Reeza
Super User

@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;
Amy0223
Quartz | Level 8
Thank you very much for your kind help! I greatly appreciate it!
Amy0223
Quartz | Level 8

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;
Tom
Super User Tom
Super User

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?

Amy0223
Quartz | Level 8
Yes, I'll try this again using array. Thank you so much!

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 5 replies
  • 1024 views
  • 0 likes
  • 3 in conversation