I imagine this was meant to go to the list.
Eva
---------- Forwarded message ----------
From: Jacob Wegelin <[email protected]>
Date: 2008/10/6
Subject: Re: st: to check if a variable already exists
To: Eva Poen <[email protected]>
Dear Eva,
Thank you. For the record (in case anyone else is as in need of this
information as I am), here is a way to do it.
capture program drop myTRY
program define myTRY
capture confirm variable `1'
if _rc==0 {
di "`1' already exists, so ..."
}
else {
di "`1' does not exist yet, so maybe we want to first
generate it ..."
}
end
myTRY "dogAndCAT"
myTRY dogAndCat
myTRY Age
Jake
Re: st: to check if a variable already exists