Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Combining SVY with Dtable

    I have found the dtable command to be exceptionally helpful but I have survey data that I am trying to use this command with. However, when I try to use it with the survey command, I get the following error "dtable is not supported by svy with vce(linearized); see help svy estimation for a list of Stata estimation commands that are
    supported by svy"

    I have a lot of variables and do not want to manually enter them. How do I solve this?


    ----------------------- copy starting from the next line -----------------------
    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input long sampl byte(stratid psuid sex race age) float(height weight) int(bpsystol bpdiast) byte(heartatk diabetes) long(finalwgt leadwt) byte(female black orace region1 region2 region3 region4 smsa1 smsa2 smsa3 rural)
    1400 1 1 1 1 54 174.598  62.48 106  80 0 0  8995     0 0 0 0 0 0 1 0 0 1 0 0
    1401 1 1 2 1 41 152.297  48.76 108  66 0 0 25964 53543 1 0 0 0 0 1 0 0 1 0 0
    1402 1 1 2 3 21 164.098  67.25  98  66 0 0  8752     0 1 0 1 0 0 1 0 1 0 0 0
    1404 1 1 2 1 63 162.598  94.46 180  80 0 1  4310     0 1 0 0 0 0 1 0 0 1 0 0
    1405 1 1 2 1 64 163.098  74.28 120  76 0 0  9011 19286 1 0 0 0 0 1 0 1 0 0 0
    1406 1 1 2 1 63 147.098     66 180  90 0 0  4310     0 1 0 0 0 0 1 0 1 0 0 0
    1407 1 1 2 1 67 153.898  54.55 100  74 0 0  3201  6457 1 0 0 0 0 1 0 1 0 0 0
    1408 1 1 2 1 57     160  58.97 154  90 0 0 25386     0 1 0 0 0 0 1 0 0 1 0 0
    1410 1 1 2 1 68     164  68.95 120  76 0 0 12102     0 1 0 0 0 0 1 0 0 1 0 0
    1411 1 1 1 2 68 176.598  65.43 104  66 0 0  4312 10031 0 1 0 0 0 1 0 0 1 0 0
    1412 1 1 2 1 70 156.199  76.77 186  96 0 0  4031     0 1 0 0 0 0 1 0 0 1 0 0
    1413 1 1 2 2 60 170.098   58.4  90  70 0 0  3628  8642 1 1 0 0 0 1 0 0 1 0 0
    1414 1 1 2 1 36 151.797  65.77 104  60 0 0 28590     0 1 0 0 0 0 1 0 0 1 0 0
    1415 1 1 2 1 24 154.199  48.54 100  66 0 0 22754 48227 1 0 0 0 0 1 0 0 1 0 0
    1417 1 1 1 2 32 171.098  73.03 110  82 0 0  7119 14186 0 1 0 0 0 1 0 0 1 0 0
    1418 1 1 1 2 68 169.297  68.72 140  70 0 1  3781     0 0 1 0 0 0 1 0 1 0 0 0
    1419 1 1 2 1 66 151.398  88.11 156 100 0 1  9611 19388 1 0 0 0 0 1 0 1 0 0 0
    1420 1 1 2 1 73     162  68.04 154  60 0 0 13802     0 1 0 0 0 0 1 0 0 1 0 0
    1421 1 1 2 1 73 171.797  61.58 130  66 0 0  4031  8609 1 0 0 0 0 1 0 0 1 0 0
    1423 1 1 1 1 66 170.098   52.5 136  84 0 0  3588  8126 0 0 0 0 0 1 0 1 0 0 0
    1424 1 1 2 1 57 153.297  68.38 160 100 0 0  8623     0 1 0 0 0 0 1 0 0 1 0 0
    1427 1 1 1 2 52 179.398 124.51 108  80 0 1 13797 27988 0 1 0 0 0 1 0 1 0 0 0
    1428 1 1 1 1 37 173.797  66.23 122  78 0 0  8817     0 0 0 0 0 0 1 0 1 0 0 0
    1429 1 1 2 1 59 155.199  82.44 126  76 0 0 25386 54087 1 0 0 0 0 1 0 0 1 0 0
    1430 1 1 1 1 60 178.398  85.62 126  80 0 0  9058     0 0 0 0 0 0 1 0 0 1 0 0
    1431 1 1 1 1 34     173  69.06 118  82 0 0  9153 19295 0 0 0 0 0 1 0 0 1 0 0
    1432 1 1 2 1 64 140.398  47.97 120  82 0 0  3035     0 1 0 0 0 0 1 0 0 1 0 0
    1433 1 1 2 1 57     163  74.16 120  68 0 0  8868 19287 1 0 0 0 0 1 0 0 1 0 0
    1434 1 1 2 2 29 159.297  66.79  96  76 0 0 27018     0 1 1 0 0 0 1 0 0 1 0 0
    1435 1 1 1 1 68 152.797  76.09 154  94 0 0  2881  6164 0 0 0 0 0 1 0 0 1 0 0
    1437 1 1 1 1 64 178.797  82.33 144  84 0 0 10292 18041 0 0 0 0 0 1 0 0 1 0 0
    1438 1 1 2 2 34 164.898  81.87 114  86 0 0 10392     0 1 1 0 0 0 1 0 0 1 0 0
    1439 1 1 2 1 22 165.297  57.61  90  68 0 0 23205 51533 1 0 0 0 0 1 0 0 1 0 0
    1441 1 1 1 1 62 154.699  66.23 160 100 0 0  3799  8151 0 0 0 0 0 1 0 1 0 0 0
    1442 1 1 1 1 53   161.5  58.51 110  70 0 0  8747     0 0 0 0 0 0 1 0 1 0 0 0
    1445 1 1 2 1 74 144.398  55.34 160  80 0 0  4597 11232 1 0 0 0 0 1 0 0 1 0 0
    1446 1 1 2 1 27   171.5  58.85  84  60 0 0 28255     0 1 0 0 0 0 1 0 0 1 0 0
    1448 1 1 2 2 29 162.797  67.59 104  78 0 0 10392     0 1 1 0 0 0 1 0 0 1 0 0
    1449 1 1 2 1 67 154.199  64.07 150  94 0 0 13802 33722 1 0 0 0 0 1 0 0 1 0 0
    1450 1 1 1 1 64 160.598  62.94 132  84 0 0 11405     0 0 0 0 0 0 1 0 0 1 0 0
    1451 1 1 1 1 72 169.199   69.4 136  84 0 0  8651 18508 0 0 0 0 0 1 0 0 1 0 0
    1452 1 1 1 1 29 171.297  70.99 116  80 0 0 26725     0 0 0 0 0 0 1 0 0 1 0 0
    1453 1 1 1 2 25     174  87.77 122  74 0 0  8221 16444 0 1 0 0 0 1 0 1 0 0 0
    1454 1 1 2 1 70 149.098  48.76 110  64 0 0  4031     0 1 0 0 0 0 1 0 1 0 0 0
    1455 1 1 2 1 70 147.598  62.26 130  76 0 0 13802 33722 1 0 0 0 0 1 0 0 1 0 0
    1456 1 1 1 1 65 172.699  89.81 120  90 1 0  2881     0 0 0 0 0 0 1 0 1 0 0 0
    1457 1 1 1 1 55   171.5  59.76 118  82 0 0  9815 19876 0 0 0 0 0 1 0 1 0 0 0
    1458 1 1 1 1 42 192.797  79.49 110  78 0 0 27889     0 0 0 0 0 0 1 0 1 0 0 0
    1459 1 1 2 2 63 169.398 102.51 196  90 0 0  3628  8642 1 1 0 0 0 1 0 0 1 0 0
    1460 1 1 1 1 36     176  65.55 104  80 0 0  8646     0 0 0 0 0 0 1 0 0 1 0 0
    1462 1 1 2 1 48 156.398  54.32 134  88 0 0  9682     0 1 0 0 0 0 1 0 0 1 0 0
    1463 1 1 1 3 36 171.699  56.13 106  66 0 0  8646 18672 0 0 1 0 0 1 0 1 0 0 0
    1465 1 1 1 1 25   167.5   74.5 140  78 0 0 26205 54109 0 0 0 0 0 1 0 0 1 0 0
    1466 1 1 1 1 28 185.398  81.65 140  98 0 0 27482     0 0 0 0 0 0 1 0 0 1 0 0
    1467 1 1 2 1 60 149.199  62.94 130  80 0 0  4310 11172 1 0 0 0 0 1 0 0 1 0 0
    1468 1 1 2 1 38     160  57.72 120  76 0 0  8648     0 1 0 0 0 0 1 0 0 1 0 0
    1469 1 1 1 2 41   180.5 113.29 140 100 0 0 31965 57643 0 1 0 0 0 1 0 0 1 0 0
    1472 1 1 1 1 62 172.398  58.29 146  88 0 0  9159     0 0 0 0 0 0 1 0 0 1 0 0
    1473 1 1 1 2 64 176.398  93.78 226 120 0 0 12689 32124 0 1 0 0 0 1 0 0 1 0 0
    1479 1 1 2 1 68 158.598  78.93 186  86 0 0  3201  6457 1 0 0 0 0 1 0 0 1 0 0
    1481 1 1 2 1 21     177  65.32 100  70 0 0 23205 51533 1 0 0 0 0 1 0 0 1 0 0
    1482 1 1 1 1 40     200  87.77 126  76 0 0 29977     0 0 0 0 0 0 1 0 0 1 0 0
    1483 1 1 1 2 26 169.699  58.29 130  66 0 0  7260 15158 0 1 0 0 0 1 0 1 0 0 0
    1484 1 1 2 2 52 160.699  90.72 170 106 0 0 11156     0 1 1 0 0 0 1 0 1 0 0 0
    1485 1 1 1 1 70 172.098  83.58 156  66 0 0  8651 18508 0 0 0 0 0 1 0 0 1 0 0
    1486 1 1 1 1 57 169.398  70.08 114  80 0 0 25519     0 0 0 0 0 0 1 0 0 1 0 0
    1490 1 1 1 2 24 185.797   74.5 128  68 0 0 11052     0 0 1 0 0 0 1 0 0 1 0 0
    1492 1 1 2 1 72 152.699     88 146  90 0 1  4031     0 1 0 0 0 0 1 0 1 0 0 0
    1493 1 1 1 2 66 171.797  90.83 176 100 0 0 11351 23083 0 1 0 0 0 1 0 0 1 0 0
    1495 1 1 2 1 70     158   52.5 174  96 0 0  9611 19388 1 0 0 0 0 1 0 0 1 0 0
    1496 1 1 1 1 71 158.699   64.3 170  80 1 0 12286     0 0 0 0 0 0 1 0 0 1 0 0
    1497 1 1 1 1 73 167.699  70.99 130  58 0 0 10773 24399 0 0 0 0 0 1 0 1 0 0 0
    1499 1 1 2 1 69 160.699  89.93 116  80 0 1  4031  8609 1 0 0 0 0 1 0 1 0 0 0
    1500 1 1 2 2 63   156.5  82.33 174 116 0 0  4138     0 1 1 0 0 0 1 0 1 0 0 0
    1503 1 1 1 1 72 153.598   65.2 134  78 0 0 12286 31833 0 0 0 0 0 1 0 0 1 0 0
    1506 1 1 1 2 24   167.5   52.5 126 100 0 0 11052     0 0 1 0 0 0 1 0 0 1 0 0
    1507 1 1 1 1 49 185.598  79.27 110  70 0 0 25750 51477 0 0 0 0 0 1 0 0 1 0 0
    1508 1 1 1 1 41 187.398  94.92 120  80 0 0  9067     0 0 0 0 0 0 1 0 1 0 0 0
    1510 1 1 1 1 67 176.297  81.08 146  84 0 0  9721     0 0 0 0 0 0 1 0 1 0 0 0
    1511 1 1 2 1 22 162.797  80.63  94  80 0 0  7729 17164 1 0 0 0 0 1 0 0 1 0 0
    1512 1 1 2 1 71 155.297  61.92 140  70 1 0  4031     0 1 0 0 0 0 1 0 1 0 0 0
    1513 1 1 2 1 60 167.699  82.78 160  82 0 0  9011 19286 1 0 0 0 0 1 0 0 1 0 0
    1514 1 1 1 1 43 179.598  81.99 128  88 0 0 27889     0 0 0 0 0 0 1 0 0 1 0 0
    1515 1 1 2 1 52 157.199  62.03 124  78 0 0 29070 58545 1 0 0 0 0 1 0 0 1 0 0
    1517 1 1 2 1 43 167.898  57.95 112  84 0 0 25964 53543 1 0 0 0 0 1 0 0 1 0 0
    1518 1 1 1 2 70 169.098  75.52 108  60 0 1  3781     0 0 1 0 0 0 1 0 0 1 0 0
    1520 1 1 2 1 71 154.699  64.18 136  78 0 0  4597     0 1 0 0 0 0 1 0 0 1 0 0
    1521 1 1 2 1 46 161.297  70.87 108  66 0 0 28268 58430 1 0 0 0 0 1 0 0 1 0 0
    1522 1 1 2 1 48     157  89.81 128  86 0 0  9415     0 1 0 0 0 0 1 0 0 1 0 0
    1526 1 1 2 2 38 156.898  69.97 108  84 0 0 10986     0 1 1 0 0 0 1 0 1 0 0 0
    1527 1 1 2 2 57   146.5  61.92 142  86 0 0  9375 21074 1 1 0 0 0 1 0 0 1 0 0
    1529 1 1 2 1 52 149.898  83.24 124  76 0 0  9415 19461 1 0 0 0 0 1 0 0 1 0 0
    1531 1 1 2 1 54   163.5  68.04 140  78 1 0 27718 54681 1 0 0 0 0 1 0 0 1 0 0
    1532 1 1 1 1 73 176.898  54.55 124  76 0 0 21545     0 0 0 0 0 0 1 0 1 0 0 0
    1533 1 1 2 2 61     170   91.4 154 100 0 1  7256 17284 1 1 0 0 0 1 0 0 1 0 0
    1536 1 1 2 1 55 176.699 137.44 134  90 0 0  9764     0 1 0 0 0 0 1 0 0 1 0 0
    1540 1 1 1 1 64   159.5  46.61 124  76 0 0  3799     0 0 0 0 0 0 1 0 0 1 0 0
    1541 1 1 2 1 24 156.398  52.16  96  70 0 1 26276 55904 1 0 0 0 0 1 0 0 1 0 0
    1542 1 1 2 1 71 150.598  43.09 128  72 0 0  4031     0 1 0 0 0 0 1 0 1 0 0 0
    1544 1 1 1 1 62 144.797  60.67 150 104 0 1 11405     0 0 0 0 0 0 1 0 0 1 0 0
    end
    label values psuid psulbl
    label def psulbl 1 "PSU 1", modify
    label values sex sex
    label def sex 1 "Male", modify
    label def sex 2 "Female", modify
    label values race race
    label def race 1 "White", modify
    label def race 2 "Black", modify
    label def race 3 "Other", modify
    label values heartatk heartlbl
    label def heartlbl 0 "No heart attack", modify
    label def heartlbl 1 "Had heart attack", modify
    label values diabetes diabetes
    label def diabetes 0 "Not diabetic", modify
    label def diabetes 1 "Diabetic", modify
    label values female female
    label def female 0 "Male", modify
    label def female 1 "Female", modify
    label values black black
    label def black 0 "Not Black", modify
    label def black 1 "Black", modify
    label values orace orace
    label def orace 0 "Black or White", modify
    label def orace 1 "Other race", modify
    label values rural rurallbl
    label def rurallbl 0 "Urban", modify
    ------------------ copy up to and including the previous line ------------------

    Code:
    svyset psuid [pweight=finalwgt], strata(stratid)
    Code:
    svy: dtable i.sex i.race age height weight i.diabetes, by(heartatk, tests) export(table1.docx)

  • #2
    svy does not support dtable, exactly as the error message states. However, dtable allows weights, so I think

    Code:
    dtable i.sex i.race age height weight i.diabetes [pw=finalwgt], by(heartatk, tests)
    gives you what you want.

    Comment


    • #3
      With dtable, svy is used as an option instead of at the beginning. try:

      Code:
       
       dtable i.sex i.race age height weight i.diabetes, by(heartatk, tests) svy export(table1.docx)

      Comment

      Working...
      X