Statalist The Stata Listserver

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

Re: st: Invalid Syntax - Drop

From   Philip Ryan <>
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.


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


Quoting Socrates Mokkas <>:

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

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
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:

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