Search code examples
datedate-conversion

How to convert CRSP date type into normal date type YYMMDD?


I am struggling with an issue of converting the date type of CRSP dataset into a normal date type such as YYMMDD. My CRSP dataset is downloaded as a SAS format but the date is represented by SAS integer number such as 7456.

Anyone know how to convert the SAS integer number into a normal date format YYMMDD? I will be very grateful for your help!


Solution

  • SAS stores dates as the number of days using 0 to mean 1960-01-01. So depending on what system you are using you just would need to add 7,456 days to the value your system uses to store January 1, 1960.

    data _null_;
      input date ;
      put date comma7. +1 date date9. +1 date yymmdd10. ;
    cards;
    0
    7456
    ;
    
    
        0 01JAN1960 1960-01-01
    7,456 31MAY1980 1980-05-31