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

st: re: count variable


From   Kit Baum <[email protected]>
To   [email protected]
Subject   st: re: count variable
Date   Sat, 2 Apr 2005 20:44:39 -0500

My previous solution created a dummy, not a counter, and I see that is not what is wanted. Andrew Felton's solution

sort ccode years
by ccode: gen nukecount = sum(nukes)

could also be written as

bys ccode (years): gen nukecount = sum(nukes)

although one would hope that since this is panel data that it has been declared as such by tsset; in that case no sorting is required.

But Paul Millar is wrong: GENERATE's sum function creates a running sum, not a constant as does EGEN's sum function. generate sum is indeed the right tool here.

Kit Baum, Boston College Economics
http://ideas.repec.org/e/pba1.html

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