asdocx tabulate with svy


asdocx works the same way with svy:tabulate command as it does with any other Stata command. We need to add asdocx to the beginning of the command line. This post shows the results from the Stata results window and asdocx for comparison for several key options of the svy:tabulate command. Let’s start with the default case, where we shall tabulate two variables without any tabulation options.

Default case: no options


 * use some example data  
 webuse nhanes2b 
 
 * default case: no option 
 svy: tabulate race diabetes

* The same if option cell is used
svy: tabulate race diabetes, cell
-------------------------------------
1=white,  |
2=black,  |   diabetes, 1=yes, 0=no  
3=other   |       0        1    Total
----------+--------------------------
    White |    .851    .0281    .8791
    Black |   .0899    .0056    .0955
    Other |   .0248  5.2e-04    .0253
          | 
    Total |   .9658    .0342        1
-------------------------------------
  Key:  cell proportion

  Pearson:
    Uncorrected   chi2(2)         =   21.3483
    Design-based  F(1.52, 47.26)  =   15.0056     P = 0.0000

asdocx results

asdocx svy: tabulate race diabetes
Tabulation of race diabetes
1=white, 2=black, 3=other diabetes, 1=yes, 0=no
0 1 Total
White 85.104 2.809 87.913
Black 8.989 0.564 9.553
Other 2.483 0.052 2.535
Total 96.575 3.425 100
Pearson Chi2 15.49
Prob. 0.0001

Weighted counts


svy: tabulate race diabetes , count

  svy: tabulate race diabetes, count  format(%14.0g)
(running tabulate on estimation sample)

Number of strata   =        31                Number of obs     =       10,349
Number of PSUs     =        62                Population size   =  117,131,111
                                              Design df         =           31

-------------------------------------------
1=white,  |
2=black,  |      diabetes, 1=yes, 0=no     
3=other   |         0          1      Total
----------+--------------------------------
    White |  99682793    3290354  102973147
    Black |  10528681     660555   11189236
    Other |   2908356      60372    2968728
          | 
    Total | 113119830    4011281  117131111
-------------------------------------------
  Key:  weighted count

  Pearson:
    Uncorrected   chi2(2)         =   21.3483
    Design-based  F(1.52, 47.26)  =   15.0056     P = 0.0000

asdocx results

asdocx svy: tabulate race diabetes , count
Tabulation of race diabetes
1=white, 2=black, 3=other diabetes, 1=yes, 0=no
0 1 Total
White 99682793 3290354 1.030e+08
Black 10528681 660555 11189236
Other 2908356 60372 2968728
Total 1.131e+08 4011281 1.171e+08
Pearson Chi2 15.49
Prob. 0.0001

 

Weighted counts and row percentages


* When option row and count are used together

 svy: tabulate race diabetes,  count row format(%9.0g)
----------------------------------------
1=white,  |
2=black,  |    diabetes, 1=yes, 0=no    
3=other   |        0         1     Total
----------+-----------------------------
    White | 9.97e+07   3290354  1.03e+08
          | .9680465  .0319535         1
          | 
    Black | 1.05e+07    660555  1.12e+07
          | .9409651  .0590349         1
          | 
    Other |  2908356     60372   2968728
          |  .979664   .020336         1
          | 
    Total | 1.13e+08   4011281  1.17e+08
          | .9657539  .0342461         1
----------------------------------------
  Key:  weighted count
        row proportion

  Pearson:
    Uncorrected   chi2(2)         =   21.3483
    Design-based  F(1.52, 47.26)  =   15.0056     P = 0.0000

asdocx svy: tabulate race diabetes , replace count row
Tabulation of race diabetes
1=white, 2=black, 3=other diabetes, 1=yes, 0=no
0 1 Total
White 99682793 3290354 1.030e+08
96.805 3.195 100
Black 10528681 660555 11189236
94.097 5.903 100
Other 2908356 60372 2968728
97.966 2.034 100
Total 1.131e+08 4011281 1.171e+08
96.575 3.425 100
Pearson Chi2 15.49
Prob. 0.0001

 

Weighted counts and column percentages


 * Weighted counts and column percentages
 svy: tabulate race diabetes , count col
 
Number of strata = 31 Number of obs = 10,349 Number of PSUs = 62 Population size = 117,131,111 Design df = 31 ------------------------------------------- 1=white, | 2=black, | diabetes, 1=yes, 0=no 3=other | 0 1 Total ----------+-------------------------------- White | 99682793 3290354 1.030e+08 | .88121413 .82027512 .87912721 | Black | 10528681 660555 11189236 | .09307547 .16467433 .09552745 | Other | 2908356 60372 2968728 | .0257104 .01505055 .02534534 | Total | 1.131e+08 4011281 1.171e+08 | 1 1 1 ------------------------------------------- Key: weighted count column proportion Pearson: Uncorrected chi2(2) = 21.34 Design-based F(1.52, 47.26) = 15.005 P = 0.000
* using asdocx asdocx svy: tabulate race diabetes , count col
Tabulation of race diabetes
1=white, 2=black, 3=other diabetes, 1=yes, 0=no
0 1 Total
White 99682793 3290354 1.030e+08
88.121 82.028 87.913
Black 10528681 660555 11189236
9.308 16.467 9.553
Other 2908356 60372 2968728
2.571 1.505 2.535
Total 1.131e+08 4011281 1.171e+08
100 100 100
Pearson Chi2 15.49
Prob. 0.0001

column and row percentages


 *column and row percentages
 svy: tabulate race diabetes , col row 
 
------------------------------- 1=white, | diabetes, 1=yes, 2=black, | 0=no 3=other | 0 1 Total ----------+-------------------- White | .968 .032 1 | .8812 .8203 .8791 | Black | .941 .059 1 | .0931 .1647 .0955 | Other | .9797 .0203 1 | .0257 .0151 .0253 | Total | .9658 .0342 1 | 1 1 1 ------------------------------- Key: row proportion column proportion
* using asdocx asdocx svy: tabulate race diabetes , row col
Tabulation of race diabetes
1=white, 2=black, 3=other diabetes, 1=yes, 0=no
0 1 Total
White 96.805 3.195 100
88.121 82.028 87.913
Black 94.097 5.903 100
9.308 16.467 9.553
Other 97.966 2.034 100
2.571 1.505 2.535
Total 96.575 3.425 100
100 100 100
Pearson Chi2 15.49
Prob. 0.0001

Weighted counts, column and row percentages


 *Weighted counts, column and row percentages
 svy: tabulate race diabetes , col row count
 
-------------------------------------
1=white,  |
2=black,  |   diabetes, 1=yes, 0=no  
3=other   |       0        1    Total
----------+--------------------------
    White | 1.0e+08  3.3e+06  1.0e+08
          |    .968     .032        1
          |   .8812    .8203    .8791
          | 
    Black | 1.1e+07  6.6e+05  1.1e+07
          |    .941     .059        1
          |   .0931    .1647    .0955
          | 
    Other | 2.9e+06  6.0e+04  3.0e+06
          |   .9797    .0203        1
          |   .0257    .0151    .0253
          | 
    Total | 1.1e+08  4.0e+06  1.2e+08
          |   .9658    .0342        1
          |       1        1        1
-------------------------------------
  Key:  weighted count
        row proportion
        column proportion

* using asdocx asdocx svy: tabulate race diabetes , row col count
Tabulation of race diabetes
1=white, 2=black, 3=other diabetes, 1=yes, 0=no
0 1 Total
White 99682793 3290354 1.030e+08
96.805 3.195 100
88.121 82.028 87.913
Black 10528681 660555 11189236
94.097 5.903 100
9.308 16.467 9.553
Other 2908356 60372 2968728
97.966 2.034 100
2.571 1.505 2.535
Total 1.131e+08 4011281 1.171e+08
96.575 3.425 100
100 100 100
Pearson Chi2 15.49
Prob. 0.0001