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)
Output 17.7 PROC PRINT Output of Work.Sch1 (Dallas)
Output 17.8 PROC PRINT Output of Work.Sch1 (Seattle)