BookmarkSubscribeRSS Feed
Sofia2022
Fluorite | Level 6
Hi
 
We currently have 2 surveys (Survey_One and Survey_two). Survey_one contains 11 questions (item 1 to 11) and survey_two contains 10 questions (item 1 to 10).  I want to create a variable that indicate a survey is considered complete if 9 of 11 questions are not missing for survey_one and if 8 of 10 questions for suverve_two are not missing.  (Variable name e.g: complete (1=yes, 0=no)).
 
For example,
person_ID=1 completed Survey_one and item1 to item3 are missing and so complete=0
person_ID=2 completed Survey_one and none of the questions/items are missing and so complete=1
 
Below is a sample of the data.
person_ID item1 item2 item3 item4 item5 item6 item7 item8 item9 item10 item11 Survey_number
1 . . . 2 2 3 3 3 2 0 0 Survey_One
2 1 3 0 0 4 1 4 3 4 3 3 Survey_One
3 0 0 0 0 0 0 2 2 0 0 0 Survey_One
4 1 2 1 1 1 1 3 3 2 1 1 Survey_One
5 1 0 0 0 0 0 0 1 2 0 . Survey_two
6 0 0 0 0 0 0 0 0 1 0 . Survey_two
7 0 2 0 0 0 0 3 3 1 0 . Survey_two
8 0 0 0 . 0 . 1 . 1 1 . Survey_two
9 0 1 0 0 0 0 1 0 0 0 . Survey_two
10 1 3 3 0 2 . . 0 2 3 . Survey_two
11 2 0 4 0 0 3 1 2 0 0 . Survey_two
 
Thanks
3 REPLIES 3
andreas_lds
Jade | Level 19

Following your description id=1 must have complete = 1 because 8 item-variables are non-missing.

Sofia2022
Fluorite | Level 6
Apologies there was an error in my post which I corrected now. ID=1 completed survey_one that contains 11 questions item1 to item11, where 3 of the items are missing and so complete=0.
PaigeMiller
Diamond | Level 26

UNTESTED CODE

 

data want;
    set have;
    if survey_number="Survey_One" then complete=nmiss(of item1-item11)<=2;
    else if survey_number='Survey_Two' then complete=nmiss(of item1-item10)<=2;
run;

 

If you want tested code, please provide data as working SAS data step code.

--
Paige Miller

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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