BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Denali
Quartz | Level 8

Hi All,

 

I have a dataset with 200 participants who filled out 5 questions. How do I delete those participants who had missing response in any 3 out of 5 questions?

 

Thank you!

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

If each respondent's data is a single observation then something similar to this should work. You did not provide the names of any variables in your data set so I am using the dummy names Var1 through Var5 to represent the five variables you are requiring.

Assume that if 4 or 5 are missing that you want to remove them as well. If ONLY exactly 3 variable then use = or EQ in place of GE (greater than or equal). CMISS will accept character or numeric variables. You did not say which type your variables might be and other solutions may require more knowledge of your data.

data want;
   set have;
   if cmiss(var1, var2, var3, var4, var5) ge 3 then delete.
run;

IF your data is not a single observation per respondent then you need to provide examples of what your data may actually look like.

View solution in original post

2 REPLIES 2
PeterClemmensen
Tourmaline | Level 20

It depends highly on the structure of your data. Please provide some sample data in usable form and your expected result.

ballardw
Super User

If each respondent's data is a single observation then something similar to this should work. You did not provide the names of any variables in your data set so I am using the dummy names Var1 through Var5 to represent the five variables you are requiring.

Assume that if 4 or 5 are missing that you want to remove them as well. If ONLY exactly 3 variable then use = or EQ in place of GE (greater than or equal). CMISS will accept character or numeric variables. You did not say which type your variables might be and other solutions may require more knowledge of your data.

data want;
   set have;
   if cmiss(var1, var2, var3, var4, var5) ge 3 then delete.
run;

IF your data is not a single observation per respondent then you need to provide examples of what your data may actually look like.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 2 replies
  • 1128 views
  • 3 likes
  • 3 in conversation