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

Re: st: count (Stata 8)

From   Heather Gold <>
Subject   Re: st: count (Stata 8)
Date   Tue, 10 May 2005 12:18:23 -0400

At 11:44 AM 5/10/2005, I wrote:
Thanks for the replies thus far.
I'd prefer a scalar so I don't have to generate the extra variables with a value attached to each subject.

Based on all the comments you have generously offered, I'm closer to a solution:

forvalues i=1995/1998 {
count if dxflag==1 & year==`i'
scalar cases`i' = r(N)
count if year==`i'
scalar total`i' = r(N)
scalar prev`i' = cases`i'/total`i'
The problem is this doesn't give me different denominators (ie, total for each year)...thoughts?
NO - this isn't a problem. This scalar approach works just an error on my part...
Debate about whether to use -generate- instead. Offline, Austin Nichols suggested a way with -generate- that excludes 1 case from the numerator to generate prevalence for everyone else, not the case at hand. I'll send to you if you're interested.

Thanks again for all the replies -

* For searches and help try:

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