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

* For searches and help try:

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