Hi everyone, I have a question that is two-fold.
I am using the svy suite of commands in Stata 18. I have a huge survey dataset that includes over 100 variables. I am trying to create tables that contain each of the 17 variables listed below in local vars (age4_new through ruralurban) stratfied by the other survey variables. I want the localvars in the rows and the other variable in the columns. The code below includes an example of one of the other (column) variables called "whyunins." The code below produces multiple tables (e.g. age4_new x whyuins, race x whyunins) and my first question is this: Is there a different coding process that I could use to create one large table with all the local vars on the rows and the other variable (whyunins, in this case) in the columns?
My second question is this: How do I export the results with the row percentages to Excel once I have the output? I have already output the column percentage tables using the dtable command and it was easy enough to use "collect" to export the results to Excel. However, I cannot figure out how to use the collect function to export ROW percentages using the svy commands. I have tried many ways and, while collect will output an Excel spreadsheet, the spreadsheet is empty.
local vars age4_new race hispanic gender sexor maritalstatus edu income ///
fulltime parttime retired student employment_other selfemployed ///
unemployed party ruralurban
foreach var of local vars {
svy: tab `var' whyunins, row count
}
Any guidance is appreciated! Thank you!
I am using the svy suite of commands in Stata 18. I have a huge survey dataset that includes over 100 variables. I am trying to create tables that contain each of the 17 variables listed below in local vars (age4_new through ruralurban) stratfied by the other survey variables. I want the localvars in the rows and the other variable in the columns. The code below includes an example of one of the other (column) variables called "whyunins." The code below produces multiple tables (e.g. age4_new x whyuins, race x whyunins) and my first question is this: Is there a different coding process that I could use to create one large table with all the local vars on the rows and the other variable (whyunins, in this case) in the columns?
My second question is this: How do I export the results with the row percentages to Excel once I have the output? I have already output the column percentage tables using the dtable command and it was easy enough to use "collect" to export the results to Excel. However, I cannot figure out how to use the collect function to export ROW percentages using the svy commands. I have tried many ways and, while collect will output an Excel spreadsheet, the spreadsheet is empty.
local vars age4_new race hispanic gender sexor maritalstatus edu income ///
fulltime parttime retired student employment_other selfemployed ///
unemployed party ruralurban
foreach var of local vars {
svy: tab `var' whyunins, row count
}
Any guidance is appreciated! Thank you!

Comment