Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | "Jessica Kopsic" <jkops@andrew.cmu.edu> |
To | statalist@hsphsun2.harvard.edu |
Subject | st: "Replace all" for a dataset |
Date | Wed, 28 Dec 2011 16:14:20 -0500 |
Hello list members, I'm trying to do the equivalent of Excel's replace all in a Stata dataset, changing the words "missing" and "not available" to a missing value for all variables in the entire dataset. This works fine for one variable: replace variable1 = "." if variable1 =="missing" replace variable1 = "." if variable1 =="not available" But I need to do the whole dataset. I tried using * in the above commands but it did not work. (returned the message: * invalid name) I also tried to write two loops, but got a type mismatch error: foreach var of varlist variable1-variable200 { replace `var' = "." if `var' = "missing" } (The variables are all string which I can't change until I change "missing" to missing values. Aside from "missing" and "not available" the variables are numbers.) Or perhaps there is a third, easier way. Thank you! Jessica * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/