DAY(), MONTH() and YEAR() are the simple DATE functions in SAS belonging to same category. Each of these functions takes a SAS date as the only argument and returns a numeric value representing the part of the date. Like DAY of the Month, Month and Year etc.
This has been demonstrated below;
1. SAS DAY( ), MONTH( ), YEAR( ) Functions
SYNTAX:
DAY(sasdate);
MONTH(sasdate);
YEAR(sasdate);
Example: SAS DAY( ), MONTH( ) and YEAR( ) Functions
SAS Code:
data temp;
sasdate = "10NOV2009"d;
day = day(sasdate);
month = month(sasdate);
year = year(sasdate);
format sasdate date9.;
run;
proc print data = temp;
run;
PROC PRINT OUTPUT :
* Please note this code has compiled on SAS 9.2 Platform.
As seen above; day function has returned the day number of the month in the given date.
Month function has returned the month number of the year.
And year has returned the value of year in YYYY format.