Reputation: 57
This may be a simple question but I want to subtract 6 days from 01/09/2012 and keep the format of DD/MM/YYYY how would I do this. Also if I compare this with another date in the same format does SAS actually compare the dates so if I said
If (Date1<Date2) /*Does this work in SAS */
Upvotes: 0
Views: 6403
Reputation: 12691
SAS dates are simply stored as the number of days since 01JAN1960 - so just subtract six :-) See my log:
44 data _null_;
45 date1 = '01SEP2012'd;
46 date2 = date1 - 6;
47 put date2= ddmmyys10.; /* the format you need */
48 if (date1 < date2) then put 'false'; /* this DOES work in SAS */
49 else put date1= date2=; /* unformatted - num of days*/
50 run;
date2=26/08/2012
date1=19237 date2=19231
Upvotes: 1