Statalist


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

st: RE: RE: Drop variables satisfying a condition


From   "Mak, Timothy" <Timothy.Mak@iop.kcl.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: RE: RE: Drop variables satisfying a condition
Date   Fri, 6 Jul 2007 17:02:04 +0100

You can use -ds- to identify your non-string variables, and loop over
these only. If you want to drop the empty string variables also, you
might want to -destring- your variables first, and then use -ds- to seek
out the non-string, and then use the loop to drop. 

Tim 
 

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Guillermo
Villa
Sent: 06 July 2007 15:22
To: statalist@hsphsun2.harvard.edu
Subject: st: RE: Drop variables satisfying a condition

Hi,

Thanks, but I think the loop does not work with strings, so it stops
when it finds the first string in the dataset. Do you think it is
possible to write a similar loop for any variable format? I have a huge
dataset, with about 500 variables, so this will be very helpful.

Thanks again.

Guillermo

-----Mensaje original-----
De: Guillermo Villa [mailto:guillermo@baphealth.com] Enviado el:
viernes, 06 de julio de 2007 14:33
Para: 'statalist@hsphsun2.harvard.edu'
Asunto: Drop variables satisfying a condition

> Dear statalisters,
>
> I wonder whether it is possible to drop several variables in a dataset

> specifying an "if" condition. For instance, it would be interesting 
> being able to drop all variables in the dataset for which all cases 
> are 0 or missing values. I have been reading the help documentation on

> the "drop" command, however I am unable to find the right answer so 
> far. Note that I want to drop variables and not cases.
>
> Thanks in advance.
>
> Guillermo
>
>

*
*   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/

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index