Svend's suggestion is more general than he implies.
The variables need not be in order. So long as some
wildcard
w0????
or
w05??? w06??? w07??? w08??? w08??? w10000
includes the variables in question, and no others,
then this approach can be applied.
I'd forgotten about -anymatch()-, which given its
history, is ironic, or a sign of mental decline.
Nick
[email protected]
Svend Juul
> Ni Frank wrote:
>
> 1) There are 50 varialbes, w05100, w05200,....,w10000. We want to DROP
> those obversations for which at least one of the above variables takes
> value of 0.
>
> 2) Now, if we want to KEEP those obersvations for which at
> least one of
> the variables w05100, w05200, ....,w09900 takes value of 0. How to do
> that?
> -----------------------------------------------------------
>
> Nick Cox gave a suggestion and some comments. Here is another
> suggestion. I assume that the variables w05000-w10000 are in
> sequence in
> the dataset (no intervening variables):
>
> egen x=anymatch(w05100-w10000) , values(0)
> drop if x==1
>
> and (2):
>
> keep if x==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/