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

Re: st: Creating weights


From   "Svend Juul" <[email protected]>
To   <[email protected]>
Subject   Re: st: Creating weights
Date   Wed, 9 Nov 2005 12:28:49 +0100

Ilaria wrote:
I have the population per zipcode of all postcodes of a country. I wanna
create a weight, which results from the population per zipcode divided
by total population.

My questions:
1. The population per zipcode is repeated many times in the file. To
make the weight I only need to count it once. How can I do so?
2. I don't have the value for the total population. How can I have it?
--------------------------------------------------------------

If yout have the two variables -zip- and -pop- you can:

    sort zip
    drop if zip==zip[_n-1]
    egen totpop=total(pop)
    gen wgt=pop/totpop

Hope this helps
Svend
__________________________________________

Svend Juul
Institut for Folkesundhed, Afdeling for Epidemiologi
(Institute of Public Health, Department of Epidemiology)
Vennelyst Boulevard 6
DK-8000  Aarhus C, Denmark
Phone: +45 8942 6090
Home:  +45 8693 7796
Email: [email protected]
__________________________________________

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



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