Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Phil Schumm <pschumm@uchicago.edu> |
To | statalist@hsphsun2.harvard.edu |
Subject | Re: st: "Replace all" for a dataset |
Date | Wed, 28 Dec 2011 15:55:22 -0600 |
On Dec 28, 2011, at 3:14 PM, Jessica Kopsic wrote: > (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. If you don't care about preserving the distinction between "missing" and "not available", then destring variable1-variable200, ignore("missingnotavailable") replace is quickest. Alternatively, if you want to preserve the distinction, try: ds variable1-variable200, has(type string) foreach var of varlist `r(varlist)' { replace `var' = ".a" if strpos(`var',"missing") replace `var' = ".b" if strpos(`var',"not available") destring `var', replace } -- Phil * * 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/