SAS Chapter 11: Creating And Using Macro Programs

10 Questions | Total Attempts: 309

SettingsSettingsSettings
SAS Quizzes & Trivia

Practice for the SAS advance certification exam.


Questions and Answers
  • 1. 
    Which of the following is false?
    • A. 

      A %MACRO statement must always be paired with a %MEND statement.

    • B. 

      A macro definition can include macro variable references, but it cannot include SAS language statements.

    • C. 

      Only macro language statements are checked for syntax errors when the macro is compiled.

    • D. 

      Compiled macros are stored in a temporary SAS catalog by default.

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

      %macro print(vars, total); proc print data=classes; var vars; sum total; run; %mend print;

    • B. 

      %macro print('vars', 'total'); proc print data=classes; var &vars; sum &total; run; %mend print;

    • C. 

      %macro print(vars, total); proc print data=classes; var &vars; sum &total; run; %mend print;

    • D. 

      %macro print(vars, total); proc print data=classes; var :vars; sum :total; run; %mend print;

  • 3. 
    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;
    • A. 

      %printdsn(sasuser.courses, course_title days);

    • B. 

      %printdsn(dsn=sasuser.courses, vars=course_title days)

    • C. 

      %printdsn(sasuser.courses, course_title days)

    • D. 

      %printdsn(sasuser.courses, course_title, days)

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

      You must list positional parameters before any keyword parameters.

    • B. 

      Values for both positional and keyword parameters are stored in a local symbol table.

    • C. 

      Default values for keyword parameters are the values that are assigned in the macro definition, whereas positional parameters have a default value of null.

    • D. 

      You can assign a null value to a keyword parameter in a call to the macro by omitting the parameter from the call.

  • 5. 
    Which of the following is false?
    • A. 

      A macro program is compiled when you submit the macro definition.

    • B. 

      A macro program is executed when you call it (%macro-name).

    • C. 

      A macro program is stored in a SAS catalog entry only after it is executed.

    • D. 

      A macro program is available for execution throughout the SAS session in which it is compiled.

  • 6. 
    When you use an %IF-%THEN statement in your macro program,
    • A. 

      You must place %DO and %END statements around code that describes the conditional action, if that code contains multiple statements.

    • B. 

      The %ELSE statement is optional.

    • C. 

      You cannot refer to DATA step variables in the logical expression of the %IF statement.

    • D. 

      All of the above.

  • 7. 
    Which of the following can be placed onto the input stack?
    • A. 

      Only whole steps.

    • B. 

      Only whole steps or whole statements.

    • C. 

      Only whole statements or pieces of text within a statement.

    • D. 

      Whole steps, whole statements, or pieces of text within statements.

  • 8. 
    Which of the following will create a macro variable named class in a local symbol table?
    • A. 

      data _null_; set sasuser.courses; %let class=course_title; run;

    • B. 

      data _null_; set sasuser.courses; call symput('class', course_title); run;

    • C. 

      %macro sample(dsn); %local class; %let class=course_title; data_null_; set &dsn; run; %mend;

    • D. 

      %global class; %macro sample(dsn); %let class=course_title; data _null_; set &dsn; run; %mend;

  • 9. 
    Which of the following examples correctly defines the macro program Hex?
    • A. 

      %macro hex(start=1, stop=10, incr=1); %local i; data _null_; %do i=&start to &stop by &incr; value=&i; put "Hexadecimal form of &i is " value hex6.; %end; run; %mend hex;

    • B. 

      %macro hex(start=1, stop=10, incr=1); %local i; data _null_; %do i=&start %to &stop %by &incr; value=&i; put "Hexadecimal form of &i is " value hex6.; %end; run; %mend hex;

    • C. 

      %macro hex(start=1, stop=10, incr=1); %local i; data _null_; %do i=&start to &stop by &incr; value=&i; put "Hexadecimal form of &i is " value hex6.; run; %mend hex;

    • D. 

      %macro hex(start=1, stop=10, incr=1); %local i; data _null_; %do i=&start to &stop by &incr; value=&i; put "Hexadeciaml form of &i is " value hex6.; %end run; %mend hex;

  • 10. 
    When you submit a call to a compiled macro, what happens?
    • A. 

      First, the macro processor checks all macro programming statements in the macro for syntax errors. Then the macro processor executes all statements in the macro.

    • B. 

      he macro processor executes compiled macro programming statements. Then any SAS programming language statements are executed by the macro processor.

    • C. 

      First, all compiled macro programming statements are executed by the macro processor. After all macro statements have been processed, any SAS language statements are passed back to the input stack in order to be passed to the compiler and then executed.

    • D. 

      The macro processor executes compiled macro statements. If any SAS language statements are encountered, they are passed back to the input stack. The macro processor pauses while those statements are passed to the compiler and then executed. Then the macro processor continues to repeat these steps until it reaches the %MEND statement.

Related Topics
Back to Top Back to top