I want to create a table in Stata 14, where the relative frequencies of the sexes are conditioned on whether the person is employed or not:
I have tried to use the community-contributed command tabout
, but I have not found a specific example that deals with this. As a workaround, I generated a variable with levels for a person that is "Male & Employed", "Female & Employed" and so on.
Is there a solution that does not require generating additional variables?
Consider the following example using Stata's auto
toy dataset:
sysuse auto, clear
egen price2 = cut(price), group(4)
label variable price2 "Price Category"
label define price2 0 "Lower" 1 "Middle" 2 "Upper" 3 "Luxury"
label values price2 price2
recode rep78 (3=1) (4=2) (5=2)
label define rep78 1 "Good" 2 "Poor"
label values rep78 rep78
The community-contributed command tab3way
provides the means to create such cross-tabulations:
tab3way price2 rep78 foreign, rowpct nofreq rowtot format(%5.2f)
Table entries are row percentages
Missing categories ignored
------------------------------------------------------------
| Car type and Repair Record 1978
Price | ------ Domestic ------ ------- Foreign ------
Category | Good Poor TOTAL Good Poor TOTAL
----------+-------------------------------------------------
Lower | 53.85 46.15 100.00 25.00 75.00 100.00
Middle | 76.92 23.08 100.00 25.00 75.00 100.00
Upper | 45.45 54.55 100.00 14.29 85.71 100.00
Luxury | 63.64 36.36 100.00 100.00 100.00
------------------------------------------------------------