Working with dates

<<< Click here to go back

Dissection of date into Day, Month and Year

Extraction of Day, Month and Year off the date :


Data Data_wid_dates;
input DOB : date9.;
format DOB date9.;
Day = Day(DOB);
Month = Month(DOB);
Year = year(DOB);
cards;
23Jan2014
01Feb1961
01Jan1960
02Jan1960
31Dec1959
;
Proc Print;
Run;

Making a Date


Data Prepare_date;
input Day Month year;
Date_full = mdy(Month, Day, Year);
format date_full ddmmyys10.;
cards;
12 2 2014
23 11 2008
7 4 2007
14 7 2012
;
proc Print;
Run;

How to write a Date in SAS


You write in like    >>>                  'DDMONYYYY'd

Data particular_date;
input dob : date9.;
format DOB date9.;
if DOB = '01Feb1961'd;
cards;
23Jan2014
01Feb1961
01Jan1960
02Jan1960
31Dec1959
;
proc Print;
Run;

That's all for this one, soon we will come up with more blogs on date functions for grown ups.


Enjoy reading our other articles and stay tuned with us.

Kindly do provide your feedback in the 'Comments' Section and share as much as possible.