%let crsid=C005; data _null_; set sasuser.courses; where course_code="&crsid"; call symput('title',trim(course_title)); run; proc print data=sasuser.schedule noobs label; where course_code="&crsid"; var location begin_date teacher; title1 "Schedule for &title"; options nodate nonumber; run;
Course_title
for
the course whose Course_code
is C005
is
assigned as a value for the macro variable title
.
The value _null_
on the data statement is
used because we do not need a data set to be created in this example.
title
.
Then you would need to resubmit the PROC PRINT step. Although you
would need to resubmit both the DATA step and the PROC PRINT step,
these two steps would be identical to the steps that you submitted
for the first report. This is an extremely inefficient program. %let crsid=C004; data _null_; set sasuser.courses; where course_code="&crsid"; call symput('title',trim(course_title)); run; proc print data=sasuser.schedule noobs label; where course_code="&crsid"; var location begin_date teacher; title1 "Schedule for &title"; options nodate nonumber; run;
General form, SYMPUT
routine with DATA step expressions:
CALL SYMPUT(expression1,expression2);
expression1
evaluates to a character
value that is a valid macro variable name. This value should change
each time you want to create another macro variable.
expression2
is the value that you
want to assign to a specific macro variable.
|
Course_code
and
to assign the corresponding value of Course_title
to
each macro variable. That is, for each observation in Sasuser.Courses,
the macro processor creates a new macro variable. The new macro variable
has the same name as the value of the data set variable Course_code
for
that observation. The value of the new macro variable is the value
of the data set variable Course_title
for
that observation. data _null_;
set sasuser.courses;
call symput(course_code, trim(course_title));
run;
%put _user_;
2 data _null_; 3 set sasuser.courses; 4 call symput(course_code, trim(course_title)); 5 run; NOTE: There were 6 observations read from the dataset SASUSER.COURSES. NOTE: DATA statement used: real time 0.52 seconds cpu time 0.13 seconds 7 %put _user_; GLOBAL C006 Computer Aided Design GLOBAL C001 Basic Telecommunications GLOBAL C002 Structured Query Language GLOBAL C003 Local Area Networks GLOBAL C004 Database Design GLOBAL C005 Artificial Intelligence |
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 &c005"; run; %let crsid=C002; proc print data=sasuser.schedule noobs label; where course_code="&crsid"; var location begin_date teacher; title1 "Schedule for &c002"; run;