Friday, December 31, 2010

SAS 1001 Tips - Tip 2 - Finding Number of days between two dates

num_day=datdif(sdate,edate,'act/act');
where
sdate=start date
edate=end date.
eg:

data a;
sdate='21jan2008'd;
edate='31dec2010'd;
num_day=datdif(sdate,edate,'act/act');
put _all_;
run;
sdate=17552 edate=18627 num_day=1075 _ERROR_=0 _N_=1
NOTE: The data set WORK.A has 1 observations and 3 variables.

1 comment:

Data Monster - Insight Monster said...

If edate=today() then the number of days will be until today.