07-21-2013 04:47 PM
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?
07-21-2013 05:23 PM
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:
put your_date_var= var_test=;
in the case of 01JAN1960 for your_date_var, you should see the following in your log:
07-22-2013 10:26 AM
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*/;
format datevar1 8. datevar2 8.;