Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Re: Cleaning messy data
From
daniel klein <[email protected]>
To
[email protected]
Subject
Re: st: Re: Cleaning messy data
Date
Mon, 28 Nov 2011 19:12:14 +0100
Martyn,
based on what you have now, something like the following could work.
replace dpr4 = subinstr(dpr4, "y", "*365", .)
replace dpr4 = subinstr(dpr4, "m", "*28", .)
replace dpr4 = subinstr(dpr4, "d", "", .)
replace dpr4 = subinstr(dpr4, " ", "+")
// note the missing spaces between "*" and "#"
encode dpr4 ,g(new)
qui su new ,mean
forv j = 1/`r(max)' {
qui replace new = `: lab new `j'' if new == `j'
}
This is a little ad-hoc and might neither be the most elegant nor the
fastest solution.
Best
Daniel
*
* 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/