Scenario 6

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:
%let job=Analyst;                                   /*1*/
data work.staff;                                    /*2*/
   keep employeeID jobtitle salary;
   set certadv.staff;
   where jobtitle contains "&job";                  /*3*/
   total+salary;
   count+1;
   call symputx('avg',put(total/count,dollar9.));   /*4*/
run;
title "&job Staff";                                 /*5*/
footnote "Average Salary: &avg";                    /*6*/
proc print data=work.staff;
   sum salary;
run;
1 The %LET statement creates the macro variable Job and assigns the value of Analyst.
2 The DATA step creates a temporary SAS data set Work.Staff. Work.Staff that contains only the variables that are defined in the KEEP statement and reads in Certadv.Staff with only those variables.
3 The WHERE statement subsets the Work.Staff data set by the including those rows where the value of JobTitle equals the value of the macro variable Job.
4 The CALL SYMPUTX routine creates a new macro variable named Avg. The macro variable’s value is the value of Total divided by the value of Count. It also formats the value of Avg to DOLLAR9.
5 The TITLE statement references the Job macro variable where the value is included in the title of the report.
6 The FOOTNOTE statement references the Avg macro variable where the value is included in the footnote of the report.
Output 17.9 PROC PRINT of Work.Staff
PROC PRINT of Work.Staff

Test Your Code Solution

  1. Correct Answer: $47,469
  2. 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
3.12.161.102