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 implements 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(sasuser.courses, course_title days);
    2. %printdsn(dsn=sasuser.courses, vars=course_title days)
    3. %printdsn(sasuser.courses, course_title days)
    4. %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?
    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 (%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,
    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 placed onto the input stack?
    1. only whole steps.
    2. only whole steps or whole statements.
    3. only whole statements or pieces of text within a statement.
    4. whole steps, whole statements, or pieces of text within statements.
  8. Which of the following creates a macro variable named class in a local symbol table?
    1. data _null_;
         set sasuser.courses;
         %let class=course_title;
      run;
    2. data _null_;
         set sasuser.courses;
         call symput('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;
  9. Which of the following examples correctly defines the macro program Hex?
    1. %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;
    2. %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;
    3. %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;
    4. %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;
  10. When you submit a call to a compiled macro, what happens?
    1. 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.
    2. The macro processor executes compiled macro programming statements.
      Then any SAS programming language statements are executed by the macro processor.
    3. 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.
    4. 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.
..................Content has been hidden....................

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