Bookmark and Share

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]

st: AW: converting varying formats of string dates into Stata dates


From   "Martin Weiss" <[email protected]>
To   <[email protected]>
Subject   st: AW: converting varying formats of string dates into Stata dates
Date   Thu, 29 Jul 2010 16:38:32 +0200

<> 

You can peel this off one by one using -separate- with an expression:


*************
clear*

inp str9 todate1 
 "30-Jun-99"
 "10/15/99"
 "4/15/1998"
 "4/15/1998"
 "8/15/1998"
 "3/15/00"
 "6/1/1998"
 "6/1/1998"
 "1-MAR-00"
 "1-MAR-00"
 "1-MAR-00"
 "1-MAR-00"
 "02/15/98"
 "12/01/98"
 "1-AUG-00"
 "8/15/1998"
 "8/15/1998"
 "6/30/1998"
 "6/30/1998"
 "7/1/1999"
end

gen mydate=date(todate1, "MD20Y")
//weed out the ones still missing
separate todate1, by(mi(mydate))

list, noo
*************

Then it is on to the next set of problematic dates...


HTH
Martin

-----Ursprüngliche Nachricht-----
Von: [email protected]
[mailto:[email protected]] Im Auftrag von Kate Rohrbaugh
Gesendet: Donnerstag, 29. Juli 2010 16:22
An: [email protected]
Betreff: st: converting varying formats of string dates into Stata dates

Greetings Statalist:
 
First, I hope my attempts at removing the HTML text were successful.  If
not, apologies in advance.

Second I have several fields that have dates in all sorts of manner, for
example (and there are more types, like mar-01-2000, this is just a
smattering):

. l2 todate1 in 1/20

  +-----------+
  |   todate1 |
  |-----------|
  | 30-Jun-99 |
  |  10/15/99 |
  | 4/15/1998 |
  | 4/15/1998 |
  | 8/15/1998 |
  |-----------|
  |   3/15/00 |
  |  6/1/1998 |
  |  6/1/1998 |
  |  1-MAR-00 |
  |  1-MAR-00 |
  |-----------|
  |  1-MAR-00 |
  |  1-MAR-00 |
  |  02/15/98 |
  |  12/01/98 |
  |  1-AUG-00 |
  |-----------|
  | 8/15/1998 |
  | 8/15/1998 |
  | 6/30/1998 |
  | 6/30/1998 |
  |  7/1/1999 |
  +-----------+

Is there an ado-file or function out there that can help fix this?  We have
something called chgdate, but it assumes that all the variables are in
"xx/xx/xxxx" format and drops everything else.  My goal is to have 1
variable that has a date in the Stata date format.

Thank you!

Kate




Kate Rohrbaugh
Research Team Leader
Research and Special Studies
Independent Project Analysis, Inc.
44426 Atwater Drive
Ashburn, VA  20147
 
direct - 703.726.5465
front desk - 703.729.8300
fax - 703.729.8301
email - [email protected]
website - www.ipaglobal.com



*
*   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/


*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index