Help using Base SAS procedures

convert dates to SAS date value

Occasional Contributor
Posts: 8

convert dates to SAS date value

Hi SAS newbie here

I am importing a excel spreadsheet with 2 date columns (lets say date1 and date2) which are formatted liked this

dd/mm/yyyy and yyyy-mm-dd

SAS is reading both of these dates like this


I would like to convert both of these to SAS data values.

So for example 01/01/1960/1960-01-01 would be 0

How can I do this?



Respected Advisor
Posts: 3,124

Re: convert dates to SAS date value

I suspect that you already have the SAS date values, where you are seeing is the Format. I am not going to burden you with some SAS statements/procedures to show the format or remove them, as you said you are 'newbie', here is a simple test to see the TRUE value of your date variables:

data _null_;

set yourtable;


put your_date_var= var_test=;


in the case of 01JAN1960 for your_date_var, you should see the following in your log:

your_date_var=01JAN1960 var_test=0


Occasional Contributor
Posts: 13

Re: convert dates to SAS date value

If possible then share your code with us I will modified the the code

Occasional Contributor
Posts: 8

Re: convert dates to SAS date value

Thanks that helped. i managed to put it into a set.

Super Contributor
Posts: 339

Re: convert dates to SAS date value


Given that the date informat and format are different after your import, it is very likely that these dates are already stored as SAS date values but that the format=date9. on your variable turns them into the 01JAN1960 that you are seeing.

There are different ways to clear out the output format so that you see the actual days count since 01JAN1960. I would use something like

proc datasets library=work nolist /*or wherever else than work your DS is stored*/;

     modify datasetname;

          format datevar1 8. datevar2 8.;



Ask a Question
Discussion stats
  • 4 replies
  • 4 in conversation