Statalist The Stata Listserver


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

Re: st: Invalid Syntax - Drop


From   Philip Ryan <[email protected]>
To   [email protected]
Subject   Re: st: Invalid Syntax - Drop
Date   Sun, 29 Oct 2006 23:39:16 +1030

-help drop- shows that the syntax:

 -drop varlist-

does not permit an -if- qualifier.

Perhaps:

foreach var of varlist cross* {
qui su `var'
if `r(max)'==0 {
drop `var'
}
}


Phil

Quoting Socrates Mokkas <[email protected]>:

> Hello All,
>
> I have a problem with dropping variables. This is my small loop:
>
> foreach var of varlist cross* {
> 	qui su `var'
> 	drop `var' if `r(max)'==0
> }
>
> Why is the invalid syntax comming up? What I want to do is to drop variables
> ( included in the varlist cross*) if they have values only of zeros or
> missing values. Am I missing the obvious here?
>
> Thanks a lot!
>
> Regards,
> Socrates
> *
> *   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/
>


-- 
Philip Ryan
Associate Professor
Discipline of Public Health

Director, Data Management and Analysis Centre
Associate Dean (IT)
Faculty of Health Sciences

University of Adelaide
5005 South Australia
AUSTRALIA
CRICOS Provider Number 00123M
-----------------------------------------------------------
This email message is intended only for the addressee(s)
and contains information that may be confidential and/or
copyright.  If you are not the intended recipient please
notify the sender by reply email and immediately delete
this email. Use, disclosure or reproduction of this email
by anyone other than the intended recipient(s) is strictly
prohibited. No representation is made that this email or
any attachments are free of viruses. Virus scanning is
recommended and is the responsibility of the recipient.
*
*   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