Transforming Data with SAS Functions | |
Manipulating SAS Date Values with
Functions![]() ![]() |
![]() |
Let's look at another example of the MDY function. The data set
Dec.Review contains a variable named Day . This
variable contains the day of the month for each employee's performance appraisal.
The appraisals were all completed in December of 1998. |
SAS Data Set Dec.Review
Site | Day | Rate | Name |
Westin | 12 | A2 | Mitchell, K |
Stockton | 4 | A5 | Worton, M |
Center City | 17 | B1 | Smith, A |
The following DATA step uses the MDY function to create a new variable
named ReviewDate . This variable contains the SAS date value for
the date of each performance appraisal.
data dec.review98; set dec.review; ReviewDate=mdy(12,day,1998); run; |
SAS Data Set Dec.Review98
Site | Day | Rate | Name | ReviewDate |
Westin | 12 | A2 | Mitchell, K | 14225 |
Stockton | 4 | A5 | Worton, M | 14217 |
Center City | 17 | B1 | Smith, A | 14230 |
![]() |
If you specify an invalid date in the MDY function, SAS software assigns a missing value to the target variable. |
data dec.review98; set dec.review; ReviewDate=mdy(15,day,1998); run; |
SAS Data Set Dec.Review98
Site | Day | Rate | Name | ReviewDate |
Westin | 12 | A2 | Mitchell, K | . |
Stockton | 4 | A5 | Worton, M | . |
Center City | 17 | B1 | Smith, A | . |
![]() ![]() ![]() ![]() ![]() ![]() |
|
![]() |
![]() |
Copyright © 2002 SAS Institute Inc.,
Cary, NC, USA. All rights reserved.