Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: skip functions containing missing variables?

From   Michael Costello <>
To   statalist <>
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

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?

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index