On l�rdag, des 7, 2002, at 10:35 America/Montreal, Sophie Barthel wrote:
i have currently got a variable which can take the values 1 or 0. i
want to create a new variable which takes the values of the old one
but which will be equal to 0 once the number of 0 values in the old
variable exceeds 200.
the code i have used is
. bys progid: gen np = _n
. gen byte y = (progid==1 & np <= 200)
. drop np
Probably you would like to do the "bys progid" with some other variable
as well, such as personal id or whatever. The idea is that you sort on
the progid, and takes a running count within the progid (or possibly
'progid pid') group, and generates y as 1 only if progid is 1 and the
running number is less than or equal to 200. I am not sure I understand
the syntax of what you proposed. Does Stata accept it?
best regards
Erik
--
Erik �. S�rensen, <http://www.geocities.com/erik_oiolf/>.
phd student (economics), Norwegian School of Economics.
currently visiting Queen's University, Kingston, Ontario.
*
* 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/