Scenario 5

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:
%macro CourseLoc;                          /*1*/
proc sql noprint;
   select distinct Location into:
      loc1-
      from certadv.schedule;
quit;
%do i=1 %to &sqlobs;                       /*2*/
title "Courses Offered in &&loc&i";
proc print data=certadv.schedule;
   where location="&&loc&i";
run;
%end;
%mend CourseLoc;                           /*3*/

%Courseloc                                 /*4*/
1 The %MACRO statement defines the macro CourseLoc. The macro itself executes a PROC SQL query where a series of macro variables are created. The macro variables store distinct values of the Location column from the Certadv.Schedule data set.
2 The %DO loop executes a PROC PRINT step for different Location values. The PROC PRINT step filters the data based on the value of Location. It also adds a TITLE statement where "Courses Offered in" is constant text while the value of the location changes.
3 The %MEND statement ends the macro definition of CourseLoc.
4 The CourseLoc macro is called to execute the macro program.
Output 17.6 PROC PRINT Output of Work.Sch1 (Boston)
PROC PRINT Output of Work.Sch1 (Boston)
Output 17.7 PROC PRINT Output of Work.Sch1 (Dallas)
PROC PRINT Output of Work.Sch1 (Dallas)
Output 17.8 PROC PRINT Output of Work.Sch1 (Seattle)
PROC PRINT Output of Work.Sch1 (Seattle)

Test Your Code Solution

  1. Correct Answer: Dallas
  2. Correct Answer: 13
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