Home > Enterprise >  How to Display SAS date internal value
How to Display SAS date internal value

Time:05-03

How can I display the internal date value of a date variable in sas?

I have it currently formatted as a date in the format ddmmyy10. and I would like to display the internal date value.

I initially thought of using the datediff function to get the difference from my date and January 1st 1960 but was wondering if there were a simpler way.

Thanks in advance Alex

CodePudding user response:

Simply set it as the numeric format 8.

/* Example data */
data have;
    date = '02MAY2022'd;
    
    format date date9.;
run;

/* Change the format of date in the dataset 'have' */
proc datasets lib=work nolist;
    modify have;
        format date 8.;
quit;

Output:

date
22767

Or, in Enterprise Guide, change the format through the GUI:

enter image description here

enter image description here

CodePudding user response:

Just use a different format. Since recent dates are in the tens of thousands of days since 1/1/1960 the COMMA format would work well.

proc print data=have ;
   format date comma8. ;
run;

Or remove the format completely and let SAS use its default display method for the numbers.

proc print data=have ;
   format date ;
run;
  • Related