Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: RE: RE: Counting unique values across a set of variables: Re-sent


From   CM <cmhsieh54@yahoo.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: RE: Counting unique values across a set of variables: Re-sent
Date   Mon, 24 May 2004 11:33:06 -0700 (PDT)

Nick,

Thanks, I'm going with your first method with
reshape's.  When I get to the line below marked
"********" I get an r(198) syntax error.  What do I
have incorrect (I thought I had the semi-colons in the
right places)?

And with the last line where "countperiod > 0", that
will only subtract Z by 1 when the condition is met?  

best,
cm

-------------------
use c:\temp\Book1 ;

reshape long var , i(id) j(num) string ;

bysort id var : gen Z = _n == 1 ;
by id : replace Z = sum(Z) ;
by id : replace Z = Z[_N] ;

reshape wide var , i(id) j(num) string ;

gen countperiod = 0 ;
foreach v of var1-var10 { ;
replace countperiod = countperiod + (`v' == ".") ;
} ;   ********

replace Z = Z - (countperiod > 0) ;
*
*   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/



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