Announcement

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

  • Encoded and formated dates display Data Editor

    I am a new user and have benefitted a great deal on the posts from the Stata Forum. I have tried to find information about what could be the cause of dates displaying differently on Data Editor. I have a dataset that spans from 2006 to 2016. The variables were written in with capital letters from 2006 to 2010 (e.g. DateofBirth, DateOfInitialCounselling, etc) and from 2011 to 2016 small letters were used (e.g. dateofbirth, dateofinitialcounselling, etc). In addition, date-based variables are numeric for the period 2006 to 2010 and string for 2011 to 2016. The latter has been where my challenge is as when I use the encode command and generate a new variable with formatting the newvar with %td, values displayed show a different date for some cells. For example there is a DateofBirth "22-Apr-72" but on the dateofbirth1 (a new variable) it is "08 Aug 59" but at the top middle value slot that shows the underlying value it shows "22apr1972". Kindly assist.

  • #2
    Welcome to Statalist.

    You should not be using encode to transfrom string dates into Stata dates.

    You will want to follow the instructions for converting your string variable to a SIF daily date variable following the guidance in help datetime, which is without a doubt the most visited documentation on my system, with the second-most-visited being Chapter 24 (Working with dates and times) of the Stata User's Guide PDF available from the PDF Documentation item on Stata's Help menu. Before working with dates and times, any Stata user should read the very detailed Chapter 24 thoroughly. After that, the help datetime documentation will usually be enough to point the way. Some people may be able to remember everything without have to continually refer to the documentation, but I for one am not such a person.

    Comment

    Working...
    X