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

st: Re: simple method to identify string variables?

From   "Michael Blasnik" <>
To   <>
Subject   st: Re: simple method to identify string variables?
Date   Fri, 07 Sep 2007 14:46:14 -0400

The easiest way may be:

ds, has(type numeric)
local numvars "`r(varlist)'"
mean `numvars'

You can omit line 2 and just refer to `r(varlist)' in line 3, but I'm assuming you may want the list for other commands as well.

M Blasnik

----- Original Message ----- From: "David Radwin" <>
To: <>
Sent: Friday, September 07, 2007 2:38 PM
Subject: st: simple method to identify string variables?

Dear Statalisters,

Is there a simple way to identify string variables using an if statement? As an obviously contrived example, suppose I wanted to use the -mean- command for all numeric variables. I would get this error message:

. sysuse auto,clear
. mean _all
varlist: make: string variable not allowed

Can I limit the command to numeric variables only? I suspect there is an easy, even obvious solution, but I can't find it anywhere.


David Radwin, Principal Analyst //
Office of Student Research, University of California, Berkeley
*   For searches and help try:

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