Sample 24790: Use month, day, and year variables to create a SAS® date
The sample code on the Full Code tab illustrates how to create a SAS date using the MDY function.
For more information about date functions, see the following SAS tutorial video:
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
A SAS date is a numeric value representing the number of days that have occurred since January 1, 1960 and a given date. A SAS date can be created using the MDY function so that you supply the values for the month, day, and year values.
data one;
input month day year;
datalines;
1 1 99
02 02 2000
;
/* Use the MDY function along with variables representing the month, day, */
/* and year values to create a SAS date. A format of MMDDYY10. is applied */
/* to the date. */
data two;
set one;
sasdate=mdy(month,day,year);
format sasdate mmddyy10.;
run;
proc print;
run;
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
Obs month day year sasdate
1 1 1 99 01/01/1999
2 2 2 2000 02/02/2000
Create a SAS date using the MDY function.
Type:
Sample
Topic:
SAS Reference ==> Functions ==> Date and Time SAS Reference ==> DATA Step