Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Converting Excel string dates into Stata dates

    I have a string variable containing a date imported from Excel in the following format;

    "MM/DD/YY"

    However, MM and DD could be single digit for single digit months. That's one problem. The other problem is that the years span 1996-2015 and are not specified as 1998 or 2006 but are reported in a two digit format (e.g. 98, 06).

    I would very much appreciate a solution to this problem.

  • #2
    Try reading
    Code:
    help datetime_translation
    carefully.

    It does explain about functions like daily() or date() -- which solve both your problems.

    e.g

    Code:
    . di %td  daily("3/28/15", "MDY", 2050)
    28mar2015
    
    . di %td  daily("3/28/96", "MDY", 2050)
    28mar1996
    See also explanations given e.g. a few hours ago http://www.statalist.org/forums/foru...-chns-into-age and in hundreds of threads here.

    Comment


    • #3
      Thanks for your help.

      Comment

      Working...
      X