Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.

# st: Weighted counts with "svy" command

 From Shige Song To statalist@hsphsun2.harvard.edu Subject st: Weighted counts with "svy" command Date Wed, 14 Sep 2011 10:19:30 -0400

```Dear Colleagues,

We are trying to do an descriptive table of basic socio-demographic
and health characteristics of our 3 subpopulations of interest
(African born, Latin American born, and US born) using the National
Health Interview Survey (NHIS).  (We're using a pooled file,
2005-2009.)  In previous research we would simply use tabulate and
show both the freq and % in our descriptive table.  Now we're using
the "svyset" command and then using "svy: tabulate nativity, count" to
get the weighted counts in the dataset.  However, this command gives
the weighted counts in, apparently, the total population, not in the
dataset.  Do you know how to obtain the weighted counts in the dataset
using "svy"?  I also tried "svy: tabulate nativity, obs", but that
gives us the unweighted number of observations.  Please see the output
below:

Below, for reference, are the unweighted tabulations of our nativity
groups in our 5-year pooled file.
. tab nativity, m
Nativity |      Freq.     Percent        Cum.
--------------------+-----------------------------------
U.S. born |    231,546       77.02       77.02
Latin American born |     43,246       14.39       91.41
African Born |      1,857        0.62       92.02
Other |     23,982        7.98      100.00
--------------------+-----------------------------------
Total |    300,631      100.00

And here are the weighted counts when we use the "svy" syntax, but
they are apparently counts in the total population.  We are looking
for weighted frequencies in the dataset.
. svy: tabulate nativity, count format(%14.3gc)
(running tabulate on estimation sample)

Number of strata   =       639                 Number of obs      =     300631
Number of PSUs     =      1278                 Population size    =  222760817
Design df          =        639
-----------------------
Nativity |       count
----------+------------
U,S, bor | 185,258,131
Latin Am |  20,152,746
African |   1,246,467
Other |  16,103,473
|
Total | 222,760,817
-----------------------
Key:  count     =  weighted counts

And if we just use "svy: tabulate nativity" (with no option
specified), we get only the cell proportions, although they are
properly weighted.
. svy: tabulate nativity
(running tabulate on estimation sample)

Number of strata   =       639                 Number of obs      =     300631
Number of PSUs     =      1278                 Population size    =  222760817
Design df          =        639

-----------------------
Nativity | proportions
----------+------------
U,S, bor |       .8316
Latin Am |       .0905
African |       .0056
Other |       .0723
|
Total |           1
-----------------------
Key:  proportions  =  cell proportions

We tried using "svy: tabulation nativity, obs percent", see below, and
this gives us the weighted percents but the unweighted number of
observations in each category.  We have looked at Stata help for svy:
tabulate, but can't seem to figure this out.  We suspect it's simple.
Does anyone know how to get the weighted counts in the dataset with
svy: tabulate?
. svy: tabulate nativity, obs percent format(%14.3gc)
(running tabulate on estimation sample)

Number of strata   =       639                 Number of obs      =     300631
Number of PSUs     =      1278                 Population size    =  222760817
Design df          =        639

------------------------------------
Nativity | percentages          obs
----------+-------------------------
U,S, bor |        83.2      231,546
Latin Am |        9.05       43,246
African |         .56        1,857
Other |        7.23       23,982
|
Total |         100      300,631
------------------------------------
Key:  percentages  =  cell percentages
obs          =  number of observations

Thanks so much for taking the time to look at this.

Best,
Shige
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```