Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: RE: Count observations previous to date


From   "David Radwin" <[email protected]>
To   <[email protected]>
Subject   st: RE: Count observations previous to date
Date   Thu, 31 May 2012 15:03:49 -0700 (PDT)

Fabian,

Is this what you want?

. bysort ccode (year) : gen ongo_cum = sum(ongo)

It doesn't seem to count cumulative number of wars but rather cumulative
years at war.

David
--
David Radwin
Senior Research Associate
MPR Associates, Inc.
2150 Shattuck Ave., Suite 800
Berkeley, CA 94704
Phone: 510-849-4942
Fax: 510-849-0794

www.mprinc.com


> -----Original Message-----
> From: [email protected] [mailto:owner-
> [email protected]] On Behalf Of Fabian Müller
> Sent: Thursday, May 31, 2012 2:53 PM
> To: [email protected]
> Subject: st: Count observations previous to date
>
> Hey Guys,
>
> i got the following problem:
>
> I have a dataset with several countries (ccode) over time (year). Each
> Observation got a binary variable(ongo) showing if there was a war or
not.
> Now i need to create a variable for each observation counting the number
> of wars the particular country was involved until (and inclusive) to
this
> date.
>
> For example:
>
> ccode	year	ongo	count
> 200		2000	0		0
> 200		2001	1		1
> 200		2002	0		1
> 200		2003	0		1
> 200		2004	1		2
> 200		2004	1		3
>
> Can't figure out a way to do this.
>
> Tanks for Help
>
> Fabian
>
>
>
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/statalist/faq
> *   http://www.ats.ucla.edu/stat/stata/
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index