I have presented data below. The "Question1" variable was from a question where respondents could select multiple responses, hence the commas. I found code from a previous post here that adequately splits those commas to produce a nice table:
Code:
split Question1, p(,) destring tabm Question1?, transpose
Right now, the best way I can think of doing that is:
Code:
tabm Question1? if agencytype ==1 | agencytype ==2 | agencytype ==3 | agencytype ==4 | agencytype ==5 | agencytype ==6, transpose
But, I feel like there must be some more efficient way of doing this, or something I am not thinking of.
My data is below. Thank you in advance for the help.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input byte agencytype str13 Question1 3 "4" 3 "4" 2 "1,2,3" 7 "4" 1 "1,2,3,4" 5 "2" 3 "4" 11 "1,2,3" 4 "4" 1 "1,2,3,4" 10 "1,2,3,4,5" 1 "3,4,5,6" 7 "2" 5 "2" 3 "5" 5 "3,4" 5 "3" 1 "1" 1 "2,3,4" 2 "4" 12 "2,3,4,5,6" 5 "4" 9 "4" 5 "3" 3 "4" 1 "4,5,6" 5 "3,4" 1 "1,2,3,4,5,6" 3 "4" 3 "3,4" 17 "1,2,3,4,5,6" 5 "3" 2 "2" 1 "1,2,3,4,5,6" 5 "3" 9 "1,2,3,4,5,6" 3 "3" 17 "1,2,3" 5 "3" 2 "3" 3 "4" 11 "1,2,3" 4 "4" 1 "1,2,3,4" 1 "1" 1 "2,3,4" 2 "4" 12 "2,3,4,5,6" 5 "4" 9 "4" 11 "1,2,3,4,5,6" 3 "4" 4 "4" 4 "3" 9 "2" 9 "7" 1 "1" 17 "4" 2 "4" 4 "4,5" 5 "3" 2 "1,2,3" 2 "4" 8 "1,2,3" 17 "1,2,3" 5 "3" 3 "1,2,3,4,6" end
0 Response to Split destring and crosstabs
Post a Comment