Quiz

Select the best answer for each question. After completing the quiz, check your answers using the answer key in the appendix.
  1. Which of the following is false?
    1. A %MACRO statement must always be paired with a %MEND statement.
    2. A macro definition can include macro variable references, but it cannot include SAS language statements.
    3. Only macro language statements are checked for syntax errors when the macro is compiled.
    4. Compiled macros are stored in a temporary SAS catalog by default.
  2. Which of the following examples correctly defines a macro named Print that defines and resolves parameters named vars and total?
    1. %macro print(vars, total);
         proc print data=classes;
            var vars;
            sum total;
         run;
      %mend print;
    2. %macro print('vars', 'total');
         proc print data=classes;
            var &vars;
            sum &total;
         run;
      %mend print;
    3. %macro print(vars, total);
         proc print data=classes;
            var &vars;
            sum &total;
         run;
      %mend print;
    4. %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;
    1. %printdsn(certadv.courses, course_title days);
    2. %printdsn(dsn=certadv.courses, vars=course_title days)
    3. %printdsn(certadv.courses, course_title days)
    4. %printdsn(certadv.courses, course_title, days)
  4. If you use a mixed parameter list in your macro program definition, which of the following is false?
    1. You must list positional parameters before any keyword parameters.
    2. Values for both positional and keyword parameters are stored in a local symbol table.
    3. Default values for keyword parameters are the values that are assigned in the macro definition, whereas positional parameters have a default value of null.
    4. 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?
    1. A macro program is compiled when you submit the macro definition.
    2. A macro program is executed when you call it (for example, %macro-name).
    3. A macro program is stored in a SAS catalog entry only after it is executed.
    4. 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, which of the following is true?
    1. You must place %DO and %END statements around code that describes the conditional action, if that code contains multiple statements.
    2. The %ELSE statement is optional.
    3. You cannot refer to DATA step variables in the logical expression of the %IF statement.
    4. All of the above.
  7. Which of the following can be used for debugging macros?
    1. MPRINT
    2. MLOGIC
    3. comments in macro programs
    4. All of the above.
  8. Which of the following creates a macro variable named Class in a local symbol table?
    1. data _null_;
         set certadv.courses;
         %let class=course_title;
      run;
    2. data _null_;
         set certadv.courses;
         call symputx('class', course_title);
      run;
    3. %macro sample(dsn);
         %local class;
         %let class=course_title;
         data_null_;
            set &dsn;
         run;
      %mend;
    4. %global class;
      %macro sample(dsn);
         %let class=course_title;
         data _null_;
            set &dsn;
         run;
      %mend;
Last updated: October 16, 2019
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset