[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

st: Re: how to select all the numerical variable

From   Dan Blanchette <>
Subject   st: Re: how to select all the numerical variable
Date   Fri, 19 Jun 2009 13:37:49 -0400 (EDT)

So now that you have a list of all the numeric variables
in the local macro r(varlist) you need to create a -foreach- loop:

ds, has(type numeric)

foreach var of varlist `r(varlist)' {
  replace `var' = .  if `var' == 0.0001


Dan Blanchette
Research Associate
Center for Entrepreneurship and Innovation
Duke University's Fuqua School of Business

----- Original Message ----- From: "Martin Weiss" <>

sysuse auto, clear
ds, has(type numeric)
di in red "Numeric vars: `r(varlist)'"


----- Original Message ----- From: "Martin Wang" <>

To: "statalist" <>
Cc: "zwang215" <>
Sent: Friday, June 19, 2009 7:06 PM
Subject: st: how to select all the numerical variable

    Dear Statalist,

    Can I ask a question? Is there any way that I can select all the numerical variable in a dataset? For example, I want to use:

    for var equity net_income cash_fixinv : replace X=. if X==0.0001

    But I have a lot of numerical variables like equity, net_income... but I don't want to list all of them. Is there any way to get around of this?

    Many thanks in advance!


*   For searches and help try:

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