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

st: re: count variable

From   Kit Baum <>
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

* For searches and help try:

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