proc format; picture monthfmt 1-12='99' /*1*/ other ='Not a valid month'; /*2*/ run; proc print data=certadv.monsal; format month monthfmt.; /*3*/ run;
1 | The PICTURE statement creates a
template called Monthfmt in which it specifies that characters in
a range of 1 through 12 are
numeric. Using digit selectors (99) specifies the positions for the
numeric values. Using a digit selector of 1 through 9 guarantees
a leading zero for the month values of 1 through 9 .
If a digit selector of 0 is used, then there are no leading zeros. |
2 | The PICTURE statement also adds
another definition to the template. It specifies that if the value
is not between 1 through 12 inclusive,
display the value Not a valid month . |
3 | The PROC PRINT step displays the data set Certadv.Monsal. You can use the FORMAT statement to apply the custom format Monthfmt to the Month variable. |
18.191.145.193