Select the best answer
for each question. After completing the quiz, check your answers using
the answer key in the appendix.
-
Which of the following
is false?
-
A %MACRO statement must
always be paired with a %MEND statement.
-
A macro definition can
include macro variable references, but it cannot include SAS language
statements.
-
Only macro language
statements are checked for syntax errors when the macro is compiled.
-
Compiled macros are
stored in a temporary SAS catalog by default.
-
Which of the following
examples correctly defines a macro named Print that defines and resolves
parameters named vars and total?
-
%macro print(vars, total);
proc print data=classes;
var vars;
sum total;
run;
%mend print;
-
%macro print('vars', 'total');
proc print data=classes;
var &vars;
sum &total;
run;
%mend print;
-
%macro print(vars, total);
proc print data=classes;
var &vars;
sum &total;
run;
%mend print;
-
%macro print(vars, total);
proc print data=classes;
var :vars;
sum :total;
run;
%mend print;
-
Which of the following
correctly references the macro named Printdsn as shown here:
%macro printdsn(dsn,vars);
%if &vars= %then %do;
proc print data=&dsn;
title "Full Listing of %upcase(&dsn) data set";
run;
%end;
%else %do;
proc print data=&dsn;
var &vars;
title "Listing of %upcase(&dsn) data set";
run;
%end;
%mend;
-
%printdsn(certadv.courses, course_title days);
-
%printdsn(dsn=certadv.courses, vars=course_title days)
-
%printdsn(certadv.courses, course_title days)
-
%printdsn(certadv.courses, course_title, days)
-
If you use a mixed parameter
list in your macro program definition, which of the following is false?
-
You must list positional
parameters before any keyword parameters.
-
Values for both positional
and keyword parameters are stored in a local symbol table.
-
Default values for keyword
parameters are the values that are assigned in the macro definition,
whereas positional parameters have a default value of null.
-
You can assign a null
value to a keyword parameter in a call to the macro by omitting the
parameter from the call.
-
Which of the following
is false?
-
A macro program is compiled
when you submit the macro definition.
-
A macro program is executed
when you call it (for example, %macro-name
).
-
A macro program is stored
in a SAS catalog entry only after it is executed.
-
A macro program is available
for execution throughout the SAS session in which it is compiled.
-
When you use an %IF-%THEN
statement in your macro program, which of the following is true?
-
You must place %DO and
%END statements around code that describes the conditional action,
if that code contains multiple statements.
-
The %ELSE statement
is optional.
-
You cannot refer to
DATA step variables in the logical expression of the %IF statement.
-
-
Which of the following
can be used for debugging macros?
-
-
-
comments in macro programs
-
-
Which of the following
creates a macro variable named Class in a local symbol table?
-
data _null_;
set certadv.courses;
%let class=course_title;
run;
-
data _null_;
set certadv.courses;
call symputx('class', course_title);
run;
-
%macro sample(dsn);
%local class;
%let class=course_title;
data_null_;
set &dsn;
run;
%mend;
-
%global class;
%macro sample(dsn);
%let class=course_title;
data _null_;
set &dsn;
run;
%mend;