Scenario 2

Code Solution

Note: On the live exam, you will be evaluated both on the results of your code and the code itself. Your code should be similar to the following example code, but does not need to match exactly:
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.
Output 17.2 PROC PRINT Output of Certadv.Monsal with MonthFmt Template Applied (partial output)
Partial Output: PROC PRINT Output of Certadv.Monsal with MonthFmt Template Applied

Test Your Code Solution

Correct Answer: 7
Last updated: October 16, 2019
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.145.193