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

st: re: creating a count variable


From   Kit Baum <kitbaum@mac.com>
To   statalist@hsphsun2.harvard.edu
Subject   st: re: creating a count variable
Date   Sat, 2 Apr 2005 20:40:42 -0500

weapons and a 1 if it has nuclear weapons
-year: this is pretty obvious. .

The current coding I have is:

gen nukecount=0
replace nukecount=(nukecount[_n-1]+1) if ((ccode==ccode[_n-1]) &
(nukes==1) & (nukes[_n-1]==1))


How about

bys ccode: gen nukecount = (sum(nukes) > 0)

This does not deal with countries that have gone from nuclear to non-nuclear.

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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index