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

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 698 views
  • 1 like
  • 3 in conversation