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

RE: st: RE: help w/counting missing


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: RE: help w/counting missing
Date   Thu, 16 Oct 2003 19:39:07 +0100

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/



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