Exporting Confidence Intervals from svy:tab in Stata Using asdocx


When working with complex survey data in Stata, the svy:tab command offers various options for generating tabulations. However, exporting the confidence intervals from the svy:tab command can be challenging . In this blog post, we will explore how to export confidence intervals from the svy:tab command using asdocx. We will also provide various examples to illustrate the process.

The svy:tab Command

The svy:tab command in Stata is used to produce one-way and two-way tabulations for survey data. It accounts for the complex survey design and provides estimates and confidence intervals. Here is a basic example of the svy:tab command:


webuse nhanes2b
svyset psuid [pweight=finalwgt], strata(stratid)
‏‏‎ ‎
svy: tabulate race, format(%11.3g) count ci
This command generates a table with counts and confidence intervals for the variable race.

Export the table with asdocx

Beginning with version 2.4.0, asdocx now supports the svy:tab command with option ci. You can export the output to Word, Excel, LaTeX or HTML.

Example 1: Exporting Confidence Intervals and counts

Let’s start with an simple example of exporting confidence intervals for a single variable price. By default, asdocx exports the output to MS Word, with the default file name My File.docx.


webuse nhanes2b
svyset psuid [pweight=finalwgt], strata(stratid)
‏‏‎ ‎
asdocx svy: tabulate race, format(%11.3g) count ci
Note that we just added asdocx to the beginning of the Stata code, everything else remains unchanged. The command produces the following table.

Tabulation of race
Race Proportion Lower B. Upper B.
White 102999549 97060400 108938698
Black 11189236 8213964 14164508
Other 2968728 414930 5522526
Total 117157513
Notes:

asdocx options

You can use replace option to replace any exiting file with the same name. You can also use title() options to set the table title.

See also


  • tabmany – Table of multiple coded answers
  • mrtab – One- and two-way tables of multiple responses
  • fre – One-way frequency tables
  • tabcount – tabulates frequencies for up to 7 variables
  • tab3way – Three way table of frequencies and percentages
  • missings – Various utilities for managing missing values
  • tabulate, tab1, tab2
  • pctab – Percentage over a grouping variable
  • crosstab – table of means and weighted by in cross tabulations

Order asdocx


Yearly license of asdocx is available at $9.99. Its life-time license is available at $49.99. With the asdocx membership, you get :

  • Life-time license to use
  • All future updates
  • All premium templates / plugins.
Order asdocx