Sample 24621: Create custom datetime format using PROC FORMAT with PICTURE
Produce a date and time value from a SAS datetime in the form
MMDDYYYY HH:MM:SS.
Note:
Date directives can be used to create ODBC canonical datetime formats that do not require milliseconds.
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.
/**************************************************************************/
/* Directives are special characters that you can use in the picture to */
/* format date, time, or datetime values. The list of directives is in */
/* the SAS Procedures Guide in the PROC FORMAT section. The DATATYPE= */
/* option indicates which type of value is being supplied to the format. */
/* The zero before each directive indicates a leading zero should be */
/* supplied if the result is a single digit. */ */
/**************************************************************************/
proc format;
picture mydate other='%0m/%0d/%0Y %0H:%0M:%0S' (datatype=datetime);
run;
data a;
x='14feb2005 12:34:56'dt;
put x mydate.;
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.
Produce a date and time value from a SAS datetime in the form
MMDDYYYY HH:MM:SS.
| Type: | Sample |
| Topic: | SAS Reference ==> DATA Step SAS Reference ==> Procedures ==> FORMAT SAS Reference ==> Formats
|
| Date Modified: | 2006-08-30 03:02:57 |
| Date Created: | 2004-09-30 14:08:58 |
Operating System and Release Information
| SAS System | Base SAS | All | n/a | n/a |