I have two variables:
Married
, which is either Married or Not MarriedRace
, which is Black, White, or OtherI'm trying to find the percent of Married
and Black
within the whole population.
I have tried the following code:
tab married race, row
married | black other white | Total
-----------+---------------------------------+----------
married | 274 18 1,150 | 1,442
| 19.00 1.25 79.75 | 100.00
-----------+---------------------------------+----------
single | 309 8 487 | 804
| 38.43 1.00 60.57 | 100.00
-----------+---------------------------------+----------
Total | 583 26 1,637 | 2,246
| 25.96 1.16 72.89 | 100.00
However, I'm looking for 274/2246, not 274/1442 which is what the 19.00
gives me.
You can do this directly with the cell
option:
sysuse auto, clear
tabulate foreign rep78, cell
+-----------------+
| Key |
|-----------------|
| frequency |
| cell percentage |
+-----------------+
| Repair Record 1978
Car type | Poor Fair Average Good Excellent | Total
-----------+-------------------------------------------------------+----------
Domestic | 2 8 27 9 2 | 48
| 2.90 11.59 39.13 13.04 2.90 | 69.57
-----------+-------------------------------------------------------+----------
Foreign | 0 0 3 9 9 | 21
| 0.00 0.00 4.35 13.04 13.04 | 30.43
-----------+-------------------------------------------------------+----------
Total | 2 8 30 18 11 | 69
| 2.90 11.59 43.48 26.09 15.94 | 100.00