SAS Chapter 11: Creating And Using Macro Programs

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Moxleyv
M
Moxleyv
Community Contributor
Quizzes Created: 38 | Total Attempts: 21,992
| Attempts: 1,202 | Questions: 10
Please wait...
Question 1 / 10
0 %
0/100
Score 0/100
1. When you use an %IF-%THEN statement in your macro program,

Explanation

You can use %IF-%THEN statements to conditionally process code. Within a %IF-%THEN statement, you must use %DO and %END statements to enclose multiple statements. %IF-%THEN statements are similar to IF THEN statements in the DATA step, but they are part of the macro language.

Submit
Please wait...
About This Quiz
SAS Chapter 11: Creating And Using Macro Programs - Quiz

This quiz assesses knowledge in SAS Macro Programming, focusing on macro creation, parameter handling, and conditional statements. It tests the ability to define, reference, and utilize macros effectively,... see moreenhancing skills vital for advanced SAS programming. see less

2. Which of the following examples correctly defines a macro named Print that includes parameters named vars and total?

Explanation

To include positional parameters in a macro definition, you list the parameters in parentheses and separate them with commas. When the macro is executed, macro variables will be created in the local symbol table and will have the same names as the parameters. You can then use these macro variables within the macro.

Submit
3.
Which of the following will create a macro variable named class in a local symbol table?

Explanation

There are several ways to create macro variables in the local symbol table. Macro variables that are created by parameters in a macro definition or by a %LOCAL statement are always created in the local table. Macro variables that are created by a %LET statement or by the SYMPUT routine inside a macro definition might be created in the local table as well.

Submit
4. Which of the following can be placed onto the input stack?

Explanation

By using %IF-%THEN statements, you can place whole steps, individual statements, or parts of statements onto the input stack.

Submit
5. Which of the following examples correctly defines the macro program Hex?

Explanation

To define macros with %DO loops you use a %DO statement and a %END statement. Be sure to precede all keywords in the statements with percent signs since the %DO and %END statements are macro language statements. Also, be sure to end these statements with semicolons.

Submit
6. Which of the following is false?

Explanation

When you submit a macro definition, the macro is compiled and is stored in a SAS catalog. Then when you call the macro, the macro is executed. The macro is available for execution anytime throughout the current SAS session.

Submit
7. Which of the following is false?

Explanation

A macro definition must begin with a %MACRO statement and must end with a %MEND statement. The macro definition can include macro language statements as well as SAS language statements. When the macro is compiled, macro language statements are checked for syntax errors. The compiled macro is stored in a temporary SAS catalog by default.

Submit
8. When you submit a call to a compiled macro, what happens?

Explanation

When you submit a call to a compiled macro, the macro is executed. Specifically, the macro processor executes compiled macro language statements first. When any SAS language statements are encountered, the macro processor places these statements onto the input stack and pauses while they are passed to the compiler and then executed. Then the macro processor continues to repeat these steps until the %MEND statement is reached.

Submit
9. 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;

Explanation

To call a macro that includes positional parameters, you precede the macro name with a percent sign. You list the values for the macro variables that are defined by the parameters in parentheses. List values in the same order in which the parameters are listed, and separate them with commas. Remember that a macro call is not a SAS language statement and does not require a semicolon.

Submit
10. If you use a mixed parameter list in your macro program definition, which of the following is false?

Explanation

In a mixed parameter list, positional parameters must be listed before any keyword parameters. Both positional and keyword parameters create macro variables in the local symbol table. To assign a null value to a keyword parameter, you list the parameter without a value in the macro call.

Submit
View My Results

Quiz Review Timeline (Updated): Aug 21, 2023 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Aug 21, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Mar 22, 2013
    Quiz Created by
    Moxleyv
Cancel
  • All
    All (10)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
When you use an %IF-%THEN statement in your macro program,
Which of the following examples correctly defines a macro...
Which of the following will create a macro variable...
Which of the following can be placed onto the input stack?
Which of the following examples correctly defines the macro...
Which of the following is false?
Which of the following is false?
When you submit a call to a compiled macro, what happens?
Which of the following correctly references the macro...
If you use a mixed parameter list in your macro program definition,...
Alert!

Advertisement