Statalist The Stata Listserver


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

Re: st: Re: Encode string in batch way?


From   "Michael Blasnik" <michael.blasnik@verizon.net>
To   <statalist@hsphsun2.harvard.edu>
Subject   Re: st: Re: Encode string in batch way?
Date   Thu, 21 Sep 2006 07:13:51 -0400

Here's a couple of ways to check if a variable is numeric:

cap confirm numeric var myvar
if rc==0 {
...
}

or

local vtype: type myvar
if substr("`vtype'",1,3)!="str" {
...
}

It's this latter one that employs the extended macro function : type varname that actually allows you to examine the storage type for a variable.

Michael Blasnik

----- Original Message ----- From: "Jia Xiangping" <jiajoseph@googlemail.com>
To: <statalist@hsphsun2.harvard.edu>
Sent: Thursday, September 21, 2006 6:15 AM
Subject: Re: st: Re: Encode string in batch way?



Michael, thank you again. It works well now. I  am now  aware of the
usefulness of "capture", which I did not expect to use.

But, like you mentioned, how to fulfill this work in another way, to
check the variable type within the loop?  I am very curious at it
because that is the way I meant to do.
*
*   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