Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: skip functions containing missing variables?
From
Michael Costello <[email protected]>
To
statalist <[email protected]>
Subject
st: skip functions containing missing variables?
Date
Tue, 16 Nov 2010 06:51:01 -0500
Dear awesome Statalisters,
I have about 25 databases with similar (but not exactly the same)
variable lists. I want to "clean" them up by adjusting labels,
formats, etc. Is there a way to have stata simply skip an absent
variable so taht I can run the same .do file on every database? For
example:
one.dta varlist: gender age date grade speed
two.dta varlist: gender date grade speed
Since age is missing from the second database if I run a script saying
"label variable age "How old is the student?" " stata would stop
running because of an error. Or, if I tried to change the order of
the (present) variables, it would have an error when it came to the
missing age variable.
So is there a way I can avoid this error? Is there some prefix that
says: Do only when variables are present?
-Michael
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/statalist/faq
* http://www.ats.ucla.edu/stat/stata/