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" <>
To   <>
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 {


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" <>
To: <>
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:

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