Statalist


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

st: Re: simple method to identify string variables?


From   "Michael Blasnik" <[email protected]>
To   <[email protected]>
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" <[email protected]>
To: <[email protected]>
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
r(109);

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.

Thanks,

David
--
David Radwin, Principal Analyst // [email protected]
Office of Student Research, University of California, Berkeley
*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index