Richard Goldstein
> Thank you Nick (except, of course, that I feel
> a bit stupid for not having come up with one of
> these -- esp. since I have used -ds- for similar
> kinds of things in the past)
>
> > gen mymiss = 0
> >
> > foreach v of var <myvarlist> {
> > cap replace mymiss = mymiss + (`v' == "888888")
> > cap replace mymiss = mymiss + (`v' == .b)
> > }
> >
> > OR
> >
> > gen mymiss = 0
> > ds, has(type numeric)
> > foreach v of var `r(varlist)' {
> > replace mymiss = mymiss + (`v' == .b)
> > }
> > ds, has(type string)
> > foreach v of var `r(varlist)' {
> > replace mymiss = mymiss + (`v' == "888888")
> > }
The options here were only added to -ds- on 17 June 2003.
Easy to miss unless you scan -whatsnew.hlp-
assiduously and frequently.
Nick
[email protected]
*
* 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/