Transforming Data with SAS Functions | |
Manipulating SAS Date Values with
Functions![]() ![]() |
![]() |
TODAY Function
The TODAY function returns the current date from the system clock as a SAS date value. |
General form, TODAY function:
This function requires no arguments, but it must still be followed by parentheses. |
Let's add a new variable, which
contains the current date, to the data set Hrd.Temp. To create this variable, write an assignment statement
such as the following:
EditDate=today();
After this statement is added to a DATA step and the step is submitted, the
data set that contains data hrd.newtemp; set hrd.temp; EditDate=today(); run; Note: The SAS date values shown below were created by submitting this program on January 15, 2000. |
SAS Data Set Hrd.Newtemp
EndDate | EditDate |
14621 | 14624 |
14565 | 14624 |
14608 | 14624 |
Remember, to display these SAS date values in a different form, you can
associate a SAS format with the values. For example, the FORMAT statement
below associates the DATE9. format with the variable EditDate .
A portion of the output that is created by this PROC PRINT step appears below.
proc print data=hrd.newtemp; format editdate date9.; run; |
EndDate | EditDate |
14621 | 15JAN2000 |
14565 | 15JAN2000 |
14608 | 15JAN2000 |
The DATE function can also create a SAS date value from the current date.
The TODAY and DATE functions have the same form and can be used interchangeably.
actualdate=today(); actualdate=date(); |
![]() ![]() ![]() ![]() ![]() ![]() |
|
![]() |
![]() |
Copyright © 2002 SAS Institute Inc.,
Cary, NC, USA. All rights reserved.