Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: RE: syntax; option real & varname


From   David Kantor <dkantor@jhu.edu>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: syntax; option real & varname
Date   Thu, 15 Aug 2002 10:09:30 -0400

Thanks to Nick Winter for his suggestion. I did think of that method as well. Both are similar in that you test it once as a variable and once as a number -- in either order, doing the second test if the first fails. I was just wondering if I was overlooking some other simpler possibility.

-- David

At 09:46 AM 8/15/2002 -0400, you wrote:

[...]
I would get x1 as a string, and then test it after your syntax line:

   syntax , x1(string)

   capture confirm new variable `x1'
   if _rc {
      confirm number `x1'
      if _rc {
         di as error "x1() must be a new variable name or a number"
         error 198
      }
      else {
         local isvar 0
        }
   }
   else {
      local isvar 1
   }
[...]
David Kantor
Institute for Policy Studies
Johns Hopkins University
dkantor@jhu.edu
410-516-5404

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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