# st: how to generate the weights after sample and assign svyset

 From Anna Gueorguieva To statalist@hsphsun2.harvard.edu Subject st: how to generate the weights after sample and assign svyset Date Sun, 11 Mar 2007 10:22:16 -0700 (PDT)

```Dear Statalist,
Would greatly appreciate your help with my two questions:
1. What weights correspond to my sample statement
2. How to svyset my 2 stage sample

1. I used the following code to generate my sample schools within each strata:

set seed  123456789
sample 4.28, by(lgacode numschools)

I was aiming to do a probability proportional to size (pps) sample but I do not think this is it (correct me if I am wrong).

How does the by statement affect my sampling weights?

I think I just did simple random sampling and my code should be:
gen weight=1/sampling_probability=1/(.0428*numschools)

2. After the schools are sampled, teachers are sampled systematically:
One teacher within each class level as the teacher might be selected as the first, last or middle name in an alphabetized list.

So my svyset statement for the school-level dataset should be:
svyset school_code [pw=weight], strata(strata) fpc(numschools_bystrata)

and for the teacher-level dataset
gen teacher_weight=weight*(1/number_teachers_in_level)
svyset school_code [pw=teacher_weight], strata(strata) fpc(numschools_bystrata) || teacherid

Best
Anna

____________________________________________________________________________________
Looking for earth-friendly autos?
Browse Top Cars by "Green Rating" at Yahoo! Autos' Green Center.
http://autos.yahoo.com/green_center/

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```