|
1 | 1 | /************************************************************************************************
|
2 | 2 | USING DATE DIRECTIVES ON THE PICTURE STATEMENT
|
3 | 3 | This program creates formats to display dates in a customized way.
|
4 |
| - Keywords: PROC FORMAT, FORMAT, PICTURE, DATATYPE= |
| 4 | + Keywords: PROC FORMAT, FORMAT, PICTURE, DATATYPE |
5 | 5 | SAS Versions: SAS 9, SAS Viya
|
6 | 6 | Documentation: https://documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=default&docsetId=proc&docsetTarget=p1xidhqypi0fnwn1if8opjpqpbmn.htm
|
7 |
| - 1. The picture statement can create formats that can be used to display dates. Start by using PROC FORMAT with a PICTURE |
8 |
| - statement that has a datatype= option. |
9 |
| - 2. The picture statement identifies the name of the new format. It then specifies the range of values to which a template |
| 7 | + 1. The PICTURE statement can create formats that can be used to display dates. Start by using PROC FORMAT with a PICTURE |
| 8 | + statement that has a DATATYPE= option. |
| 9 | + 2. The PICTURE statement identifies the name of the new format. It then specifies the range of values to which a template |
10 | 10 | will be applied. Use the LOW and HIGH to keywords to indicate that the range includes everything from the lowest value
|
11 | 11 | to the highest.
|
12 |
| - 3. It then specifies a template or pattern for the format. In this case we use date directives to define the template. In |
13 |
| - quotes this template includes three date directives - %0d specifies that the day of the month be written out in one or two |
| 12 | + 3. The template or pattern for the format is specified. In this case we use date directives to define the template. The quoted |
| 13 | + template includes three date directives - %0d specifies that the day of the month be written out in one or two |
14 | 14 | digits, %b specifies that the month be written out in a three letter abbreviation, and %Y specifies that a 4-digit
|
15 |
| - year be written out. These elements are separated by the tilde character (~). The pattern closes with spaces to account for |
| 15 | + year be written out. These elements are separated by the tilde character (~). The pattern closes with extra spaces to account for |
16 | 16 | the length of labels.
|
17 |
| - 4. Next, in parentheses, the datatype is specified. The datatype= option can specify that the format is for a date, |
18 |
| - a time, or a datetime. |
19 |
| - 5. In the PROC PRINT apply the format and see the results. |
20 |
| - 6. Text can be combined with picture templates to create truly customized formats. Text be can be used for some levels of a |
| 17 | + 4. The DATATYPE= option specifies that the format is a date, a time, or a datetime. |
| 18 | + 5. Apply the format in PROC PRINT to view the results. |
| 19 | + 6. Text can be combined with picture templates to create truly customized formats. Text be can be used for some levels of a |
21 | 20 | format and date directives for other levels.
|
22 | 21 | 7. SAS date constants (as well as time constants and datetime constants) can be used to specify the beginning and end of
|
23 | 22 | a date range.
|
24 |
| - 8. In using date directives remember that case can matter. A lower case b results in a 3-letter abbreviation for month, while |
25 |
| - an upper case B spells out the whole month. |
| 23 | + 8. When using date directives, remember that case can matter. A lower case 'b' results in a 3-letter abbreviation for month, while |
| 24 | + an upper case 'B' spells out the whole month. |
26 | 25 | ************************************************************************************************/
|
27 | 26 |
|
28 | 27 | proc format;
|
|
0 commit comments