Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

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

RE: st: create new variable from weighted counts?

From   "Rossen, Lauren M. (CDC/OSELS/NCHS)" <>
To   "" <>
Subject   RE: st: create new variable from weighted counts?
Date   Wed, 17 Apr 2013 13:12:46 +0000

Thank you so much, Nick, for pointing me in the right direction.
There will be plenty of jumping up and down in appreciation.



Date: Tue, 16 Apr 2013 19:09:30 +0100
From: Nick Cox <>
Subject: Re: st: create new variable from weighted counts?

You could always go something like

bysort county: egen dths_white=total(wtvar * (race==1))

In a strong sense this is documented, as the -egen- -total()- function
can take an arbitrary expression as argument. However, quite how
general this is may deserve more shouting and jumping up and down than
it gets.


On 16 April 2013 18:57, Rossen, Lauren M. (CDC/OSELS/NCHS) <> wrote:
> Hello Stata-listers,
> I have a data set on all infant deaths in the US, and I am
> trying to create county-level summaries of several variables.
> For example, counts of deaths by county for white infants,
> black infants, etc.  Normally, this would be straightforward
> to do with something like:
> bysort county: egen dths_white=total(race==1)
> bysort county: egen dths_black=total(race==2)
> However, the data are weighted because a small # of
> deaths are not included in the file, so there are something
> like importance weights to make sure that the totals sum
> up to the actual total # of reported deaths in the US.
> I say importance weights because there is no sampling,
> and the weights are not integers, they range from 1 to 1.2.
> My question is: is there a way to generate new variables
> representing county-level totals incorporating the
> weights? I apologize for the rudimentary question,
> but I have tried searching through the archives and
> documentation and had no luck finding a solution.
*   For searches and help try:


*   For searches and help try:

© Copyright 1996–2016 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index