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

Re: st: Creating weights

From   "Svend Juul" <SJ@SOCI.AU.DK>
To   <>
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 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

*   For searches and help try:

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