I am not familiar with SPSS, which
I understand to be a statistical package,
but this sounds like
gen count = 0
qui foreach v of var a1-a21 {
replace count = count + (`v' == 5)
}
There is an -egen- function -rcount()-
in -egenmore- on SSC, for which the syntax
would be
egen count = rcount(a1-a21), cond(@ == 5)
but the approach from first principles
gets higher marks from -egen--haters.
Nick
[email protected]
Jason Thompson
> Is there a Stata equivalent of the SPSS count function, which
> counts the
> number of occurrences of a particular value amongst a set of
> variables?
> Something like this:
>
> count (newvar)=a1 to a21 (5), which assigns newvar the number
> of times
> a1-a21 equals 5 for each case?
>
> Nothing in egen seems to be quite what I'm looking for.
*
* 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/