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
01JAN1960
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?
Regards
Alex
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;
var_test=your_date_var;
put your_date_var= var_test=;
run;
in the case of 01JAN1960 for your_date_var, you should see the following in your log:
your_date_var=01JAN1960 var_test=0
Haikuo
If possible then share your code with us I will modified the the code
Thanks that helped. i managed to put it into a set.
Hi
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.;
run;
quit;
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.