Hello,
I have a list of 15k respondents (each has a customer id), who have answered questions about the no. of pets they have (ranges 0 - as many pets they have). I have 6 variables (1 for no. of dogs, 2 for no. of cats, etc.): Q15_1 Q15_2 ... Q15_6
Irrespective of the type of pet and the no. of pets under each category, I need to find the no. of respondents with more than 1 pet.
For example, if respondent 23 has answered that he has 2 dogs (Q15_1) and 1 cat (Q15_2), and respondent 42 has answered that he has 2 cats (Q15_2) , they should both be regarded as respondents with more than 1 pet.
How can I do that in SAS? Is Proc Tabulate to be used for this? Any help is appreciated as I have never used it before.
Attached is sample data.
Regards,
MS
Here's a statement you can use within a DATA step. It creates a variable that is 1 when the respondent has more than 1 pet, and 0 when the respondent has 0 or 1 pet.
multiple_pets = sum(of q15_1 - q15_16) > 1;
Presumably you can work with that to get any result that you have asked for.
Can you post some sample data please? Makes it much easier to provide a usable code answer
Here's a statement you can use within a DATA step. It creates a variable that is 1 when the respondent has more than 1 pet, and 0 when the respondent has 0 or 1 pet.
multiple_pets = sum(of q15_1 - q15_16) > 1;
Presumably you can work with that to get any result that you have asked for.
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!
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.