I have a dataset that includes an open-ended response that was coded into categories by a vendor. The vendor created 50 multi-punch categories stored as 50 true/false variables.

By putting this in a multiple response set and cross-tabbing it with itself I can see that most responses seem to be in a small number of categories - the crosstab is strongly diagonal.

For the purposes of an analysis I would like to perform, the categories can only be single-punch. Short of sending this back to the vendor and having them re-categorize over 6,000 responses, I'd like to solve this programmatically if the number of affected responses is small enough. I'd like to write a syntax file that can count the number of respondents categorized into each number of categories - say, 5000 assigned to one category, 1000 assigned to two categories, 500 assigned to three, and so on... If the number assigned to multiple categories is small enough, I'd like to just throw out the ones that were assigned to multiple categories.

Is there an effective way to do this in SPSS syntax? Writing the logic for each possible pair / triplet / quadruplet of multi-response data would be impossible given that I have 50 categories. Any ideas?

  • $\begingroup$ "count the number of responses categorized into each number of categories". Please make it clearer what you want. A response can punch but a single category. It's a respondent that punches one or more categories. $\endgroup$
    – ttnphns
    Jul 6, 2011 at 19:08
  • $\begingroup$ Thanks for the question. I mean the number of respondents categorized in each number of categories, and edited the question to reflect this. Is this clear now? $\endgroup$
    – Jonathan
    Jul 6, 2011 at 19:45
  • $\begingroup$ Then Andy's answer below is relevant $\endgroup$
    – ttnphns
    Jul 6, 2011 at 19:55

1 Answer 1


It sounds like a simple sum command would work to identify if a response had multiple positive responses to the same category.

So say X1_1,X1_2,...X1_50 are the dummy variables for survey item X1. The command

compute X1_sum = SUM(X1_1 to X1_50).
freq var = X1_sum.

Would result in a variable, X1_sum, that would be a total of all the items (i.e. the number who have assigned 1 category, 2 categories, etc..). The only caveat of this is that the statement, X1_1 to X1_50 to work they need to be in order in the dataset.

You could make your own macro function to do this for all of the items, which could probably be reduced in complexity and number of parameters passed based on how your variables are coded. An example could be;

define !sum_response (name =  !TOKENS(1) 
/ begin = !TOKENS(1) 
/ end = !TOKENS(1) ).
compute !name = SUM(!begin to !end).
freq var !name.

!sum_response name = X1_sum begin = X1_1 end = X1_50.

This is not a real great example, as the produced function takes as much writing as does the original compute command. But this could be further simplified if you have other consistent naming conventions (and I can give examples if needed). Such as if all your responses have the suffix as I did above, you could reduce the macro to only passing one statement (the X1 in my example). If all the responses are coded in a similar progressive manner (e.g. X1,X2,X3...) you could write code to loop through all of the variables without needing to call the macro for each set (you could do this anyway even if the names aren't in a consistent manner, but the code would be much more verbose and perhaps would not save any time over just writing the separate calls).

I can't give any more advice without being more explicit about what you want to accomplish (such as how to handle cases that have multiple responses). I cringe about the suggestion of throwing out cases, but without knowing more I could not give any useful advice. This should get you started though, and you can either update this question or ask a new question about how to handle the multiple responses if you can't figure it out on your own.

  • $\begingroup$ Andy thanks! I didn't know about the SUM command but it looks like that will do exactly what I want. The dataset is perfectly structured for this as the variables are all in order and have a 1 as a punch. $\endgroup$
    – Jonathan
    Jul 6, 2011 at 19:48
  • $\begingroup$ I too cringe at the idea of throwing out data - but if the responses were ambiguous or included so many topics that the coder couldn't choose a single category, then the followup questions I am tying back to this could apply to any of the topics they mentioned. The open-ended question here is asking what questions they had while using a product, and the followup questions are about which support channels they used and whether their question was resolved. If I had written this questionnaire, I would have allowed the user to enter multiple questions separately. $\endgroup$
    – Jonathan
    Jul 6, 2011 at 19:55
  • $\begingroup$ Just wanted to let you know that I just used this function and it worked great - did exactly what I needed. $\endgroup$
    – Jonathan
    Jul 6, 2011 at 23:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.