Course_code
.
However, you still needed to modify the TITLE statement in each PROC
PRINT step in order to print output for each course.
data _null_;
set sasuser.courses;
call symput(course_code,trim(course_title));
run;
%let crsid=C002;
proc print data=sasuser.schedule noobs label;
where course_code="&crsid";
var location begin_date teacher;
title1 "Schedule for ???";
run;
C002
(as created by the
SYMPUT routine) has a value of Structured Query Language
.
Therefore, the TITLE statement should reference a macro variable that
resolves to Structured Query Language
.
Remember that you want this reference to be flexible enough to apply
to any of the macro variables that the SYMPUT routine creates, such
as C003
or C004
,
by changing only the %LET statement.
Structured
Query Language
, you need to indirectly reference the
macro variable C002
through a reference
to the macro variable crsid
. If the value
of the macro variable crsid
is C002,
then you need to proceed in several steps:
&&crsid
to
convert the value of the macro variable crsid
to
the corresponding course description. However, the Forward Re-Scan
rule indicates that this is not the correct solution.
crsid
to indirectly
reference the macro variable C002
.
Structured Query Language
, the original
reference must be &&&crsid
.
crsid
, you can write
a PROC PRINT step that you can reuse without modification in order
to print a report for each different course. options symbolgen; data _null_; set sasuser.courses; call symput(course_code, trim(course_title)); run; %let crsid=C005; proc print data=sasuser.schedule noobs label; where course_code="&crsid"; var location begin_date teacher; title1 "Schedule for &&&crsid"; run; %let crsid=C002; proc print data=sasuser.schedule noobs label; where course_code="&crsid"; var location begin_date teacher; title1 "Schedule for &&&crsid"; run;
43 options symbolgen; 44 data _null_; 45 set sasuser.courses; 46 call symput(course_code, trim(course_title)); 47 run; NOTE: There were 6 observations read from the dataset SASUSER.COURSES. NOTE: DATA statement used: real time 0.07 seconds cpu time 0.05 seconds 48 49 %let crsid=C005; 50 proc print data=sasuser.schedule noobs label; 51 where course_code="&crsid"; SYMBOLGEN: Macro variable CRSID resolves to C005 52 var location begin_date teacher; SYMBOLGEN: && resolves to &. SYMBOLGEN: Macro variable CRSID resolves to C005 SYMBOLGEN: Macro variable C005 resolves to Artificial Intelligence 53 title1 "Schedule for &&&crsid"; 54 run; NOTE: There were 3 observations read from the dataset SASUSER.SCHEDULE. WHERE course_code='C005'; NOTE: PROCEDURE PRINT used: real time 0.09 seconds cpu time 0.04 seconds 55 56 %let crsid=C002; 57 proc print data=sasuser.schedule noobs label; 58 where course_code="&crsid"; SYMBOLGEN: Macro variable CRSID resolves to C002 59 var location begin_date teacher; SYMBOLGEN: && resolves to &. SYMBOLGEN: Macro variable CRSID resolves to C002 SYMBOLGEN: Macro variable C002 resolves to Structured Query Language 60 title1 "Schedule for &&&crsid"; 61 run; NOTE: There were 3 observations read from the dataset SASUSER.SCHEDULE. WHERE course_code='C002'; NOTE: PROCEDURE PRINT used: real time 0.06 seconds cpu time 0.04 seconds |
teach1
to teach
n,
each containing the name of the instructor who is assigned to a specific
course. options symbolgen; data _null_; set sasuser.schedule; call symput('teach'||left(course_number), trim(teacher)); run;
||
combines
text. In the example above, the literal string teach
is
concatenated to the text that results from left-aligning the resolved
value of the variable Course_number
.
teach
n macro
variable that corresponds to the current course number. %let crs=3; proc print data=sasuser.register noobs; where course_number=&crs; var student_name paid; title1 "Roster for Course &crs"; title2 "Taught by &&teach&crs"; run;
&&teach&crs
.
65 %let crs=3; 66 proc print data=sasuser.register noobs; 67 where course_number=&crs; SYMBOLGEN: Macro variable CRS resolves to 3 68 var student_name paid; SYMBOLGEN: Macro variable CRS resolves to 3 69 title1 "Roster for Course &crs"; SYMBOLGEN: && resolves to &. SYMBOLGEN: Macro variable CRS resolves to 3 SYMBOLGEN: Macro variable TEACH3 resolves to Forest, Mr. Peter 70 title2 "Taught by &&teach&crs"; 71 run; |