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: adding or counting values as an array
From
Daniel Exeter <[email protected]>
To
"'[email protected]'" <[email protected]>
Subject
st: adding or counting values as an array
Date
Thu, 6 Oct 2011 05:49:04 +0000
Hi there
In Stata 11 (win7, 64bit), I have a dataset with quarterly observations of events from 2006 to 2011.
Each field is named y2006_q1, y2006_q2 .. y2011_2
The data is dichotomous (0/1) and I want to know:
-for the entire period (q1 2006 to q3 2011) and separately for each year
- how many quarters each event was observed
- how many quarters each event was not observed
is there an easy way to code something that would do this:
gen included = sum (yr20*) if yr20* ==1
gen excluded = count (yr20*) if yr20* ==0
and
gen inc06 = sum (yr2006*) if yr2006 ==1
gen exc06 = count(yr2006*) if yr2006 ==0
Cheers
Dan
*
* 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/