Statalist


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

Fwd: st: to check if a variable already exists


From   "Eva Poen" <[email protected]>
To   Statalist <[email protected]>
Subject   Fwd: st: to check if a variable already exists
Date   Mon, 6 Oct 2008 23:52:20 +0100

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




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