Announcement

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

  • Why does the differences between to identical date time variables produces missing values and not 0?

    Dear all,
    I am working with demographic data. My aim is to generate a variable age at death from two other variables - the birth date and the date of death. The latter two variables are in the stata date format (mdy). All works fine, however, in those cases where birth date == date of death stata generates a missing value instead of 0 (days). Since I am working with data from the early modern period there are many stillbirths for which the condition day of death == day of birth holds.

    Why does stata behave this way, and is there an elegant workaround (other than replacing age at death with 0 if birth date == date of death)?

  • #2
    Clearly it shouldn't happen that supposedly identical values are declared not just unequal but not commensurable. The display format (if that's what you mean by mdy format) isn't material here. We need an example of data for which you get such puzzling results, please.

    Comment


    • #3
      Dear Nick, I went through my code to provide an example and found my stupid coding mistake. I have some incorrect entries where the date of death is smaller than date of birth. I got rid of this by the if condition "date_of_birth > date_of death" excluding all stillbirths in the process. I am sorry for bothering you and I appreciate your time. All the best!

      Comment


      • #4
        On the contrary, it is good to get closure and to learn that there was a solution.

        Comment

        Working...
        X