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!
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.
It depends highly on the structure of your data. Please provide some sample data in usable form and your expected result.
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.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.