Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: one-way tables with survey data

From   "Steven A. Harvey" <[email protected]>
To   [email protected]
Subject   Re: st: one-way tables with survey data
Date   Tue, 14 Jun 2005 17:38:09 -0400

Nick Winter's answer works very well for unstratified variables (Thank you, Nick). This solves part of my problem, but not all of it. For many variables, I need to stratify by respondent characteristics. For example, if I want to stratify by age in a non-survey dataset, I could type:

tab agegrp myvar , r

and Stata would return percentages that add up to 100% for each row, with each row corresponding to a different age group.

but svytab doesn't allow the , r option, and when I type

svytab agegrp myvar

Stata returns a table of proportions in which the rows and columns combined add up to 1. I can't figure out a way to get row totals.

svytab also does not allow "by" statements, so I can't say "bysort agegrp: svytab myvar one" (where "one" is the constant variable mentioned in Nick's message)

The only workaround I've been able to discover so far is to use an "if" statement for each stratum:

svytab myvar one if agegrp==1
svytab myvar one if agegrp==2
svytab myvar one if agegrp==3


Very cumbersome and time-consuming, especially for characteristics with many strata (e.g., 17 provinces in the country)
This syntax also prevents me from using the syntax "for varlist varA varB varC etc: svytab X myvar"

Surely there must be a more efficient way to produce such basic information...?

Thanks again,


At 08:17 AM 6/14/2005, you wrote:


It is a limiteation of Stata 8's -svytab- that it does not do one-way tabulations directly. In version 9, this is supported.

However, this is a minor limitation, because you can create a second "variable" that is a constant, and use that as the second variable in a two-way crosstabulation. Like this:

. generate one = 1

. svytab myvar one

--Nick Winter

At 06:46 PM 6/13/2005, you wrote:

posting it again. I offer my profuse apologies if somehow it gets posted 3 times--this was not my intention.

I am working with a survey dataset and need to produce frequency distributions for a number of dichotomous variables. I have defined the dataset as survey data using the standard commands (Intercooled Stata v. 8.2):

svyset [pweight=pesomef]

The svytab command seems only to work with 2-way tables and the regular tab (tabulate, table, etc.) command produces the same result whether or not I define the data as survey data. I've read through the svytab command documentation several times as well as the documentation for table/tabulate commands and on Stata weights. Surely I'm missing something, but I can't figure out what.

Could someone please help me with the appropriate syntax to produce a weighted one-way table for these variables?

Thanks in advance,


* For searches and help try:
Nicholas Winter                           607.255.8819 t
Assistant Professor                       607.255.4530 f
Department of Government              [email protected] e
308 White Hall   w
Cornell University
Ithaca, NY 14853-4601
*   For searches and help try:

*   For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index