/* Input some dates centered around 1960, and one that isn't */ data a; input dt @@; datalines; 3650 365 -365 0 30635 ; /* Try out some date functions and inspect them */ data b; set a; today=today(); month=month(dt); day=day(dt); year=year(dt); date=mdy(month,day,year); proc print data=b; var dt date month day year today; format date mmddyy8. today worddate18.; run; /* Save the remaining Julian dates in a typical date format */ data c; set b; file 'e:\stat 540\date.txt'; put (date today dt)(mmddyy8. +1); run; /* Demonstrate some date functions */ data a; input birthdate anydtdte10.; x=today(); *These steps only approximate current age; y=(x-birthdate)/365; current_age=floor(y); *yrdif computes age accurately in SAS 9.3; current_age2=floor(yrdif(birthdate,x,'age')); current_age3=yrdif(birthdate,x,'age'); datalines; 10-14-1959 7 27 1964 1/17/62 5feb1929 ; * Print the output in an attractive format; proc print data=a; format birthdate x worddate20.; run; *Use IN operator with dates; data b; set a; if birthdate in ('14Oct1959'd '17Jan1962'd); run; proc print data=b; format birthdate worddate20.; run;