Bookmark and Share

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

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

st: weighting a count

From   N <>
Subject   st: weighting a count
Date   Fri, 12 Aug 2011 15:39:18 -0400

I'm struggling with weighting a count. I'm working on Stata/MP 11.0 for Mac.
I am working with a data set in which I want to see a count that has
been weighted based on how much data has been lost in cleaning.
So I had been working with four basic steps:
1) count the relevant data
2) clean
3) count the relevant data after cleaning
4) count the relevant instances within an age group, weighting each
count by the proportion of the data lost to cleaning, thereby
essentially scaling the data back up as though no data had been lost
to cleaning.

I am struggling both with storing the counts (steps 1 and 3), and with
weighting the later counts by these numbers (step 4). I do not just
want to type them in by hand since the code will be used for 500 or so

I had been using the -return- command to store the count like so:
program scaleup, rclass
count if fr==1
return scalar Nbefore = r(Nbefore)
However, after I cleaned the data, counted and stored r(Nafter),
scaleup r(Nbefore)
would return r(Nafter) instead.
So that was problem one: even after I got the appropriate count, I
didn't know how to store it to use it as part of an fweight later.

Further, in step 4, i want to count the data by age:
sort age
by age: count if fr==1
But I'm not sure how to scale up these counts. I want to multiply the
count for each age by 1/(1-((Nbefore-Nafter)/Nbefore)).

Would you be able to assist me in weighting these counts?
Thank you very kindly!

*   For searches and help try:

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