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: imputing dates into a string date
From
Nick Cox <[email protected]>
To
"'[email protected]'" <[email protected]>
Subject
RE: st: imputing dates into a string date
Date
Thu, 7 Jun 2012 15:35:13 +0100
I wouldn't do precisely that. There might be dates with missing months too, for all we know. That code would replace "XX/XX" with "01/01". Replacing a missing day with 1 is one thing; replacing a missing month with January messes up the data. So, ever picky, I recommend instead
g dx_clean = subinstr(dx, "XX", "01", 1)
Nick
[email protected]
daniel klein
this is (probably) much simpler than you might assume. All you need to
type is the one line
g dx_clean = subinstr(dx, "XX", "01", .)
Substitute -g dx_clean- in the code with -replace dx- if you want to
change your original variable.
Hi all,
[...]
This is working fine, until I come across a date that actually starts like this:
xx/01/2010
Then my code to generate a date returns a blank. What I would like to
do is add in something that allows me to evaluate whether the day is
xx and if so, insert 01.
*
* 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/