I am trying to make a tables from a survey dataset. I have a lot of variables representing likert-scaled survey questions, where 1 "Strongly disagree", 2 "Partly disagree", 3 "Neither agree nor disagree", 4 "Partly agree", 5 "Strongly agree", 6 "Don't know", 7 "Not relevant". What I want is tables showing the frequency of respondents having answered those categories. I need all tables to include all categories. Problem is that for some variables (questions) nobody answered 1 "Strongly disagree" nor 6 "Don't know". I still need the table to show that 0 and 0% answered that, i.e., that the frequency for values 1 and 6 on variable s18 is 0. This is not the default in -table- and apperently adding the -, zerocounts- options doesn't help. Here is what I tried:
And here is what my data looks like:
What code do I need to write in order to produce a table, that shows that the frequency for values 1 and 6 on variable s18 is 0, and then export this to Excel?
Code:
collect table () s18, zerocounts putexcel a1 = collect
Code:
* Example generated by -dataex-. For more info, type help dataex clear input byte s18 4 5 4 5 5 5 4 5 7 5 4 . . 5 5 5 . 2 4 5 3 5 . 5 5 . . 5 5 5 5 . 5 2 5 5 5 5 5 4 5 . 4 5 5 2 . 5 5 5 5 . 5 5 . 5 . 5 5 7 5 5 5 5 5 5 4 5 3 5 5 5 5 4 end
What code do I need to write in order to produce a table, that shows that the frequency for values 1 and 6 on variable s18 is 0, and then export this to Excel?
Comment