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

Re: st: how to select all the numerical variable

From   Michael Hanson <>
Subject   Re: st: how to select all the numerical variable
Date   Sat, 20 Jun 2009 09:40:26 -0400

I haven't tested the solutions proposed in this thread, but it seems possible that they may run afoul of the float problems discussed earlier in the week: see < > and subsequent thread.

If I understand the bottom line of that discussion, the solution for Dan's code would be simply to replace the appropriate line with:

replace `var' = .  if float(`var') == float(0.0001)

I'm less certain if Kit's (otherwise clever and concise) code will have float issues.

On Jun 19, 2009, at 1:37 PM, Dan Blanchette wrote:

ds, has(type numeric)

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

On Jun 19, 2009, at 2:31 PM, Kit Baum wrote:

ds, has(type numeric)
mvdecode `r(varlist)' , mv(0.0001)

On Jun 20, 2009, at 8:43 AM, Roy Wada wrote:

for var _all : cap replace X=. if X==0.0001

I'm not certain if this will work, as I cannot find a guide to the syntax of the now deprecated -for- command: -help for- simply notes that "for is an out-of-date command as of Stata 8" and recommends using -foreach- (as in Dan's example) or -forvalues-. Also, while - capture-ing all the failed replacements should work, I would expect it to be slower than the above examples, particularly as the number of non-numerical series in the OP's dataset increases. (And the above- mentioned float issue likely still exists.)


*   For searches and help try:

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