Statalist The Stata Listserver


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: Re: st: shorthand


From   "Austin Nichols" <[email protected]>
To   [email protected]
Subject   Re: Re: st: shorthand
Date   Mon, 5 Jun 2006 10:11:47 -0400

Timothy Mak--
If you wind up with logical==0 everywhere, you might have included a
string variable in your varlist... try also

gen byte allmiss = 1
ds a10*
foreach v in `r(varlist)' {
qui replace allmiss = 0 if !mi(`v' )
}
list if allmiss==1

but are you sure you want to list all variables in all observations
where all a10* are missing?  You will be listing a lot of dots...
maybe you want to

gen byte allmiss = 1
qui ds
local allvars `r(varlist)'
qui ds a10*
local avars `r(varlist)'
local tolist: list allvars - avars
foreach v of local avars {
qui replace allmiss = 0 if !mi(`v' )
}
list `tolist' if allmiss==1


On 6/5/06, n j cox <[email protected]> wrote:
This problem is no problem. Loop over
your varlist instead:

gen byte logical = 1
quietly foreach v of var <varlist> {
        replace logical = 0 if `v' < .
}

Nick
[email protected]

Timothy Mak

This is ok if my variables are a100, a101, a102, and so on, but it
wouldn't work if I have say a101a, a102a, a102b, a103_oth, and so on,
variables that have the same root but don't have other things in common...

But thanks anyway.

Dominic Muston

I'm not sure this is shorter!

gen logical==1
forvalues i=100(1)200 {
      replace logical = 0 if a`i'!=.
}
list if logical==1
*
*   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