Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: Re: Cleaning messy data


From   daniel klein <klein.daniel.81@googlemail.com>
To   statalist@hsphsun2.harvard.edu
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/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index