Announcement

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

  • Date variable after Importing SAS to Stata

    Hey all,

    I have a 2millioin observation sas dataset to be imported into STATA. I do not have sas, so I can't open it. One of the DATE variable is YearMMDD. I read the data manual online.

    I opened stata, and use the import wizard, I got the STATA data, but the DATE variable is stored as integer in %10.0g format

    for example: the first observtion has a value of 6209 for DATE

    how do I restore it to a YearMMDD, my goal is to get the year . the value of DATE in my sample ranges from 6025 to 22066


    Thank you
    Last edited by Rochelle Zhang; 09 Oct 2023, 10:43.

  • #2
    Following your first thread https://www.statalist.org/forums/for...-two-variables please post under your name Rochelle Zhang.

    6205 and 22066 are plausible daily dates in Stata. Consider

    Code:
    . di year(6025) " " year(22066)
    1976 2020
    from which it would follow that

    Code:
    gen year = year(DATE)
    would give you a year variable. See also

    Code:
    help datetime
    and

    https://www.statalist.org/forums/help#spelling

    Comment


    • #3
      Thank you Nick. I apologize not using the correct login. I only saved log in info for Rstata.

      Comment


      • #4
        OK, so please use the CONTACT US button at bottom right to get in touch with the list administrator to change your registration.

        Comment

        Working...
        X