Jacob was interested in the coarser distinction between numeric and
string.
This is just one step down the line from Austin's approach here.
sysuse auto
foreach v of varlist _all {
loc type = substr("`: type `v''", 1, 3)
if "`type'" == "str" {
di as res "`v'" as txt " is string"
}
else di as res "`v'" as txt " is numeric"
}
Also see help on -confirm-.
Nick
[email protected]
Austin Nichols
See the second entry under
help extended_fcn
or try:
sysuse auto
foreach v of varlist _all {
loc type: type `v'
di as res "`v'" as txt " is type" as res " `type'"
}
On Mon, Apr 21, 2008 at 11:01 AM, Jacob Wegelin <[email protected]>
wrote:
> The following program is a kluge to determine the type of a variable
and to
> assign a string to a local macro which tells us the type. Is there
some
> better way? For instance, "return list" after "describe myvar" or
"codebook
> myvar" does not tell us this.
*
* 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/