On Wed, 2004-02-11 at 22:55, Jason Payne wrote:
> Thank you for your help,
>
> Is there a way to list multiple cases that dont fit a standard expression in the replace command. for example:
>
> replace var1=1 if var2==1 or 3
>
> I want cases 1 and 3 to have value 1 for var1, but not case 2 and rather than writing the whole syntax twice, i would like to shorten it:
>
> replace var1=1 if caseid==1
> replace var1=1 if caseid==3
replace var1=1 if caseid==1 | caseid==3
or, more generally (if you have a big list of caseid values),
egen to_replace = eqany(caseid), v(1 3)
replace var1=1 if to_replace==1
drop to_replace
C.
*
* 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/