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

Re: st: excluding variables by type

From   Margaret R Grove <margaret.r.grove@Dartmouth.EDU>
Subject   Re: st: excluding variables by type
Date   Tue, 25 Mar 2008 12:33:23 -0400


Here's one method:

unab vlist: _all /* assign all variable names to local variable vlist */
foreach x of varlist `vlisit' {
capture confirm string variable `x'
if _rc~=0 {
/* do numeric variable processing here */
else {
/* do string processing here */


Libby Hemphill wrote:


I'm wondering if there's a way to loop through all my variables and
perform some action only on those that are numeric. Is there a way to
check for the type of the variable before doing something? Like

for each variable
if string, next
else do X
end for


*   For searches and help try:

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