SAS Date Functions DAY( ), MONTH( ) And YEAR( )

1. SAS DAY( ), MONTH( ), YEAR( ) Functions

SYNTAX:

DAY(sasdate);

MONTH(sasdate);

YEAR(sasdate);

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;

Example: SAS DAY( ), MONTH( ) and YEAR( ) Functions

SAS Code:

proc print data = temp;

run;

PROC PRINT OUTPUT :

data temp;

sasdate = "10NOV2009"d;

day = day(sasdate);

month = month(sasdate);

year = year(sasdate);

format sasdate date9.;

run;

* 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.