Bookmark and Share

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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: Domain analysis of survey data


From   Steve Samuels <[email protected]>
To   [email protected]
Subject   Re: st: Domain analysis of survey data
Date   Fri, 16 Jul 2010 20:41:15 -0400

Brad,   For the same reason that and -if- clause would be incorrect in
Stata, in SAS your use of the BY COUNTY statement for domain analysis
is also incorrect  unless each county is a top level stratum.  See the
section on "domains","subpopulations", or "subdomains" in any applied
sampling book.  In SAS, you should have used the DOMAIN statement
also.  Notice in what follows that the sample size for each regression
is 69, the total population size, because every observation enters
into the standard error calculations.

Stata allows you to mimic a "by" statement for specifying domains,
with the aid of  a -foreach- statement:

**************************CODE BEGINS**************************
sysuse auto, clear
svyset _n
drop if rep78==.
gen county = rep78
recode county 1/2=3

levelsof county, local(lv)
foreach i  of local lv {
tempvar c`i'
gen c`i' = county==`i'
di in red "County = `i'"
svy, subpop(c`i'): reg mpg weight
}
***************************CODE ENDS***************************

Steve

Steven Samuels
[email protected]
18 Cantine's Island
Saugerties NY 12477
USA
Voice: 845-246-0774
Fax:    206-202-4783



On Fri, Jul 16, 2010 at 7:14 PM, G. Dai <[email protected]> wrote:
> One clarity first. Can't use if statement in a survey because it kills
> the sample to sample variability of the survey design.
> In the case, use subpop option after svy:
> gen countyi=county==i
> svy,sub(countyi): mean agegroup race education income maritalstatus
> smokingstatus
> hth
> guang
>
>
> On Fri, Jul 16, 2010 at 3:23 PM, Brad Cannell <[email protected]> wrote:
>> Hello,
>>
>> I'm new to stata. I'm analyzing a large weighted state survey (Behavioral Risk Factor Surveillance System) to create a state report. In this report I need to do a separate descriptive table for each county in the state, which includes proportions of the county that fall into various different categories. In SAS I would have done it like this (hypothetical):
>>
>> proc surveyfreq data=statereport;
>> table agegroup race education income maritalstatus smokingstatus;
>> by county
>> weight finalweight
>> strata stratvar
>> run;
>>
>> The "by county" because that is the command that would have repeated the frequency tables of age, race, education, etc for each county.
>>
>> So far in stata I have been able to designate the dataset as survey data with the correct weight and strata variables identified. I have also been able to produce frequency tables of age, race, education, etc for the dataset as a whole using "svy: prop age race education". However, after a lot of searching I am unable to find a way to get stata to give me a separate analysis for each county. I really don't want to use "if" statements to program the analysis for each county separately. When I try "by county: svy: prop age race education" I get an error message saying that by statements can't be used with survey commands. Does anyone have a suggestion?
>>
>> Thanks,
>> Brad
>> *
>> *   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/
>



-- 
Steven Samuels
[email protected]
18 Cantine's Island
Saugerties NY 12477
USA
Voice: 845-246-0774
Fai:    206-202-4783

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


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index