# Re: st: SVY: tab with three variables

 From sjsamuels@gmail.com To statalist@hsphsun2.harvard.edu Subject Re: st: SVY: tab with three variables Date Fri, 1 May 2009 11:15:21 -0400

```Welcome to Stata!  Reposting a question will not get it answered any
faster.  See the Stata FAQ about why questions do not get answered.
with snippets of Stata code, and other  statements.

Important! Something appears wrong with your survey set up.  You have
n =  5,191 observations, but Stata reports that the total population
size is only N = 3,061,  You could be using the wrong probability
weight. Stop and fix this problem.

1. If you have survey data, you must always -svyset- with the
why, or look at Sharon Lohr, "Sampling, Design and Analysis", Duxbury
Books.

2. Your new race-ethnicity variable seems okay.  You can
cross-tabulate it against the original variable to check.

You have a potential problem if whites were not asked this question:
the survey weights might give misleading results if applied to
nonwhites alone.  This is not an elementary matter and you should
the study documentation with you when you do this.

3.  -svy: tab- with the tab() option doesn't do what you think it
does.   Read the -help- to see why.

I'm assuming that the new race-thnic variable is recoded 1 & 2.

svy, subpop(if racethn==1), tab sex psymps, row
svy, subpop(if racethn==2), tab sex psymps, row

-Steve

On Fri, May 1, 2009 at 10:01 AM, Adebola Odunlami
<aodunlam@hsph.harvard.edu> wrote:
> Hi all,
>
> I was hoping someone would please address my question below. Any help/insight is greatly appreciated.
>
> I am relatively new to stata and I have a few related questions. I want to get proportion of units that answered a question( variable name = psysymps) by thier gender(sex) and race (race3cat) after I survey set the data. I tried "bysort race3cat: tab psysymps sex, row col chi2"  but then realized the percentages were off and I needed to use svy commands. I then tried "svy: tab racet3cat sex, tab (psysymps) row se ci" but got a response that the table contains 0 in the marginals and therefore statsitics cannot be computed. I realized that one of the race categories (e.g. White) was not asked the question. So I created a new race category ("blackethn) that sets Whites to missing and others to either 1 or 2. Then I proceeded with my primary objective to see proportions of 'psysymps' by race and sex and tried "svy: tab blackethn sex, tab (psysymps) row se ci". This gave me the table below.
>
> My questions are: 1) must I always svy set before each code e.g svy: tab instead of just tab?; 2) was it okay to set Whites to missing as they were not asked this question and I dont want them counted as a denominator in my proportion?; 3) the table below still does not give me tabs of my variable by race and sex. how do I do this? Instead the table gave me---of those who answered yes to psysymps, what proportion of race/blackethn =1 were men and what prop were women? I would like to know how to code to get----what proportion of race/blackethn==1 men answered 'yes' to psysymps, compared to race/blackethn== 1 female (and also the proportion of race/blackethn ==2 men that answered yes to to psysymps, compared to race/blackethn== 2 female and associated chi2)
>
>
> Number of strata   =        41                  Number of obs      =      5191
> Number of PSUs     =        88                  Population size    = 3061.3339
>                                               Design df          =        47
>
> -------------------------------------------------------
>         |                   rs sex
> blackethn |          male         female          Total
> ----------+--------------------------------------------
>       1 |         .4019          .5981              1
>         |       (.0248)        (.0248)
>         | [.3532,.4526]  [.5474,.6468]
>         |
>       2 |         .5338          .4662              1
>         |       (.0579)        (.0579)
>         | [.4176,.6465]  [.3535,.5824]
>         |
>   Total |         .4101          .5899              1
>         |       (.0235)        (.0235)
>         | [.3638,.4581]  [.5419,.6362]
> -------------------------------------------------------
>  Tabulated variable:  psysymps
>
>  Key:  row proportions
>       (linearized standard errors of row proportions)
>       [95% confidence intervals for row proportions]
>
>  Pearson:
>   Uncorrected   chi2(1)         =   21.8483
>   Design-based  F(1, 47)        =    4.6397     P = 0.0364
>
>
>
>
> Doctoral Student
> Society, Human Development and Health
> Harvard School of Public Health
> 301 256 4655
> *
> *   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/
>

*
*   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/
```