The data below is a survey where the respondents were asked to select all that apply. So you have one responded with multiple entries. I have to tabulate the frequencies and percentages. But i need to first label the responses as follows: 1--a, 2 -- b, 3 --c, 4-- d, 5--e, 6--f, 7--g. NA is supposed to be excluded from the tabulation and the percentages are computed by dividing the frequency for each response by the total number of observations (excluding the missing values). In this this the total frequency would be more than 100%. The final table should look like the table below --
I tried using split Values , gen(Variable) parse(,)
bys MMID: gen n =_n
reshape long Variable, i(AC n)
drop if V==""
tab Variable AC
Is there a way to do the tabulation without reshaping the data? need help please.
---------------------- copy starting from the next line -----------------------
------------------ copy up to and including the previous line ------------------
| Values | Frequency | Percentage |
| a | ||
| b | ||
| c | ||
| d | ||
| e | ||
| f | ||
| g |
I tried using split Values , gen(Variable) parse(,)
bys MMID: gen n =_n
reshape long Variable, i(AC n)
drop if V==""
tab Variable AC
Is there a way to do the tabulation without reshaping the data? need help please.
---------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str13 Values "4,6" "1,2,3,6" "NA" "2,3,4,5,6,7" "1,2,3,4,5,6" "1,2,3,4,5,6" "6" "1,2,3,4,5,6" "3,6" "NA" "3,6" "1,2,3,4,5,6" "1,2,3,4,5" "2,3,4,5,6,7" "2,3,4,5,6" "1,2,3,4,5,6,7" "1,2,3,5,6" "2,4,6" "1,2,3,4,5,6" "1,2,3,4,5,6" "1,3,4,6" "2,3,6" "1,3" "1,2,3,4,5,6" "1,2,3,4,5,6" "1,2,3,4,5,6" "1,2,3,4,5,6,7" "3,6" "7" "6" "5,6" "1,2,3,4,5,6" "6,7" "1,2,3,5,7" "1,2,3,4,5,7" "4,5,6" "6" "1,2,3,4,5,6,7" "1,2,4" "1,2,3,4,5,6" "1,2,3,4,5,6" "1,2,3,4,5,6" "2,3,4,5,6,7" "1,2,3,4,5,6" "3,5,6" "1,2,3,4,5,6" "1,2,3,4,5,6,7" end

Comment