SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Quiz: Improving Program Efficiency with Macro Variables

Select the best answer for each question and click Score My Quiz.

  1. Macro variables can be defined and referenced anywhere in a SAS program except within...

     a.   data lines
     b.   procedures
     c.   the FORMAT statement
     d.   the INPUT statement

  2. Which assignment statement will set the value of Day to a text string containing the day of the week?

     a.   Day=sysday;
     b.   Day=&sysday;
     c.   Day='&sysday';
     d.   Day="&sysday";

  3. Which statement will create a macro variable named region that has the value northwest?

     a.   %let region=northwest;
     b.   %let region='northwest';
     c.   &let region=northwest;
     d.   &let region="northwest";

  4. What is the result of including the following line in your program?

    options symbolgen;

     a.   Macro variable resolution is listed in program output.
     b.   Macro variable resolution is suppressed in program output.
     c.   Macro variable resolution is written to the SAS log.
     d.   Macro variable resolution is suppressed in the SAS log.

  5. When SAS software encounters a macro variable reference but cannot locate the macro variable, the reference is left unresolved. What happens next?

     a.   SAS software continues execution, ignoring all lines that contain the macro variable reference.
     b.   SAS software continues execution, but the unresolved reference often results in a syntax error.
     c.   SAS software continues execution, but the unresolved reference often results in a system crash.
     d.   SAS software ends program execution.

  6. Suppose your program creates a macro variable named period that contains the value End. How would you use this macro variable to reference the variable EndDate in the program?

     a.   %period&date
     b.   &period%date
     c.   &period.date
     d.   "%period"date

  7. Suppose your program creates a macro variable named libref that contains the value sales. Another macro variable, named libname, contains the value q3y2001. How would you use these macro variables to reference the data set Sales.Q3y2001?

     a.   data %libref.%libname;
     b.   data &libref..&libname;
     c.   data %libref".%libname";
     d.   data "&libref."&libname;

  8. You use the CALL SYMPUT routine to create a macro variable whose value is assigned...

     a.   by a later statement
     b.   by another macro variable
     c.   during the execution of the DATA step
     d.   during the execution of a procedure

  9. Why is a PUT function embedded in this CALL SYMPUT statement?

    call symput('total',put(totover,2.));

     a.   To ensure the conversion of numeric values to character values.
     b.   To prevent the conversion of numeric values to character values.
     c.   To resolve the macro variable reference of totover.
     d.   To remove leading blanks from the values assigned to total.

  10. What is wrong with the following program?
    title "Temporary Employees Worked &total OT Hours";
         data hrd.overtime;
            set hrd.temp(keep=name overtime) end=last;
            if overtime ne .;
            TotOver+overtime;
            if last then call
               symput('total',put(totover,2.));
         run;
         proc print data=hrd.overtime;
         run;

     a.   The PUT function is in the wrong place.
     b.   The TITLE statement is in the wrong place.
     c.   The CALL SYMPUT statement syntax is incorrect.
     d.   The CALL SYMPUT statement cannot be combined with an IF statement.



back||next

Terms of Use & Legal Information | Privacy Statement