Syntax, macro definition
that includes positional parameters:
%MACRO macro-name(parameter-1<,...,parameter-n>);
text
%MEND <macro-name>;
parameter-1<,...,parameter-n>
specifies one or more
positional parameters, separated by commas. You must supply each parameter
with a name: you cannot use a text expression to generate it.
|
%macro printdsn(dsn,vars);
proc print data=&dsn;
var &vars;
title "Listing of %upcase(&dsn) data set";
run;
%mend;
Certadv.Courses
is
assigned to the macro variable Dsn, and the value course_code
course_title days
is assigned to the macro variable
Vars. Notice that the value for Dsn is listed first and the value
for Vars is listed second, since this is the order in which they are
listed in the macro definition.
%printdsn(certadv.courses,course_code course_title days)
%printdsn(,course_code course_title days)
Syntax, macro definition
that includes keyword parameters:
%MACRO macro-name(keyword-1=<value-1><,...,keyword-n=<value-n>>);
text
%MEND <macro-name>;
keyword-1=<value-1><,...,keyword-n=<value-n>>
names one or more macro
parameters followed by equal signs. You can specify default values
after the equal signs. If you omit a default value, the keyword parameter
has a null value.
|
%macro-name(keyword-1=value-1<,...,keyword-n=value-n>)
Certadv.Courses
to
the macro variable Dsn and assigns a default value of course_code
course_title days
to the macro variable Vars: %macro printdsn(dsn=certadv.courses, vars= course_code course_title days); proc print data=&dsn; var &vars; title "Listing of %upcase(&dsn) data set"; run; %mend;
Certadv.Schedule
for
Dsn and a value of teacher course_code begin_date
for
Vars, issue the following call:
%printdsn(vars=teacher course_code begin_date, dsn=certadv.schedule)
Certadv.Courses
as
the value for Dsn and course_code course_title days
as
the value for Vars), you could issue the following call:
%printdsn()
%printdsn(dsn=certadv.courses,vars=course_code course_title days)
Syntax, macro definition
that includes mixed parameters:
%MACRO macro-name(parameter-1<,...,parameter-n>,
keyword-1=<value-1><,...,keyword-n=<value-n>>);
text
%MEND macro-name;
parameter-1<,...,parameter-n>
is listed before keyword-1=<value-1><,...,keyword-n=<value-n>>.
|
%macro-name(value-1<,...,value-n>, keyword-1=value-1<,...,keyword-n=value-n>)
%macro printdsn(dsn, vars=course_title course_code days);
proc print data=&dsn;
var &vars;
title "Listing of %upcase(&dsn) data set";
run;
%mend;
Certadv.Schedule
to
the macro variable Dsn and assigns the value teacher
location begin_date
to the macro variable Vars. Notice
that the value for Dsn is listed first, since Dsn is the positional
parameter.
%printdsn(certadv.schedule, vars=teacher location begin_date)
course_title
course_code days
to the macro variable Vars and assigning
the value Certadv.Courses
to the macro
variable Dsn. You could issue the following call:
%printdsn(certadv.courses)
3.144.107.116