BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Nrjn7
Fluorite | Level 6
IDSurveySurvey_repeatDay
1A11
1A22
2A11
2A22
2A33
2A44
2A55
3A11
3A22

 

So, every participant completes a survey 5 times, one each day. I want to calculate how many are missing.

In this case, ID 1 and 3 have 3 surveys missing. How do I tally this?

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
Use PROC FREQ to count the number of days and save that to a dataset. Then 5 - the number to see how many are missing.

proc freq data=have;
table id / out=ID_COUNTS;
run;

data want;
set ID_COUNTS;
NMISS = 5 - FREQ;
run;

View solution in original post

4 REPLIES 4
Reeza
Super User
Use PROC FREQ to count the number of days and save that to a dataset. Then 5 - the number to see how many are missing.

proc freq data=have;
table id / out=ID_COUNTS;
run;

data want;
set ID_COUNTS;
NMISS = 5 - FREQ;
run;

Nrjn7
Fluorite | Level 6

@Reeza  Thank you.

How do I approach the problem if there are multiple surveys.

Reeza
Super User
Add SURVEY into the TABLES statement.

table id*Tables / out=ID_COUNTS;
PaigeMiller
Diamond | Level 26
/* UNTESTED CODE */
proc summary data=have nway;
    class id;
    var survey_repeat;
    output out=_max_ max=survey_repeat_max;
run;
data want;
     set _max_;
     number missing = 5 - survey_repeat_max;
run;

 

If there can be multiple surveys, then use

 

class id survey;

 

--
Paige Miller
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
  • 4 replies
  • 1332 views
  • 1 like
  • 3 in conversation