Hello,
I have a wide format dataset and then each ID has 6 columns from different surveys (i.e., each variable are binary and simply indicate whether the participants responded to that survey, 0= not responded and 1=responded) . I am creating some descriptive stats to understand how many people had 1 survey missing and how many people had 2 survey missing and so on (or the other way round as how many people had responded certain number of surveys). So what I have done was first creating a string variable so that I have a pattern of the response for each participant like before.
Data response_finalsample_;
SET response_finalsample_;
length responsex $ 6;
responsex = cat (of s1-s6);
RUN;
The above is successful as I can see I've created a new column showing the string of the response like "110101" "000011" etc
But the problem arises as I would like to create a new variable so that it shows how many '0' or '1' in the string variable as above.
I thought I could use count function but it does not work because the new created variable did not match the actual number of responses of a participant.
DATA response_finalsample_;
count_miss = countc(responsex, '1');
output;
RUN;
It would be really helpful if someone could point the direction of doing this.
Thank you!