SAS Chapter 10: Processing Macro Variables At Execution Time

10 Questions | Total Attempts: 125

SettingsSettingsSettings
SAS Quizzes & Trivia

Practice for the SAS advance certification exam


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

      A %LET statement causes the macro processor to create a macro variable before the program is compiled.

    • B. 

      To create a macro variable that is based on data calculated by the DATA step, you use the SYMPUT function.

    • C. 

      Macro functions are always processed during the execution of the DATA step.

    • D. 

      Macro variable references in a DATA step are always resolved prior to DATA step execution.

  • 2. 
    Which of the following correctly creates a macro variable named region and assigns to it a value that is based on the value of the data set variable Location?
    • A. 

      data new; set sasuser.all; if location='Boston' then do; call symput('region', 'East'); end; else do; call symput('region', 'West'); end; run;

    • B. 

      data new; set sasuser.all; if location='Boston' then do; %let region=East; end; else %let region=West; end; run;

    • C. 

      data new; set sasuser.all; if location='Boston' then do; call symput(region, "East"); end; else call symput(region, "West"); end; run;

    • D. 

      data new; set sasuser.all; if location='Boston' then do; symput(region, East); end; else symput(region, West); end; run;

  • 3. 
    The SYMPUT routine cannot
    • A. 

      Be used to assign a data set variable as a value to a macro variable.

    • B. 

      Create a series of macro variables in one DATA step.

    • C. 

      Automatically convert a numeric value to a character value when used to assign a value to a macro variable in a DATA step.

    • D. 

      Be used to assign a numeric value to a macro variable in an SCL program.

  • 4. 
    Which of the following programs correctly creates a series of macro variables whose names are values of the data set variableCourse_code, then indirectly references one of those macro variables in a later step?
    • A. 

      data _null_; set sasuser.courses; call symput(course_code, trim(course_title)); %let crsid=C005; proc print data=sasuser.schedule noobs label; where course_code="&crsid"; var location begin_date teacher; title1 "Schedule for &c005"; run;

    • B. 

      data _null_; set sasuser.courses; call symput(course_code, trim(course_title)); run; %let crsid=C005; proc print data=sasuser.schedule noobs label; where course_code="&crsid"; var location begin_date teacher; title1 "Schedule for &&&crsid"; run;

    • C. 

      data _null_; set sasuser.courses; call symput('course_code', trim(course_title)); run; %let crsid=C005; proc print data=sasuser.schedule noobs label; where course_code="&crsid"; var location begin_date teacher; title1 "Schedule for &&&crsid"; run;

    • D. 

      data _null_; set sasuser.courses; call symget(course_code, trim(course_title)); run; %let crsid=C005; proc print data=sasuser.schedule noobs label; where course_code="&crsid"; var location begin_date teacher; title1 "Schedule for &&&crsid"; run;

  • 5. 
    Which of the following statements about the resolution of macro variable references is false?
    • A. 

      Two ampersands resolve to one ampersand.

    • B. 

      If more than four consecutive ampersands precede a name token, the macro processor generates an error message.

    • C. 

      Re-scanning continues until there are no remaining macro triggers that the macro processor can resolve.

    • D. 

      The macro processor always re-scans a name token that is preceded by multiple ampersands or by multiple percent signs.

  • 6. 
    In which of the following situations would you use SYMGET rather than a macro variable reference (&macvar)?
    • A. 

      To create a DATA step variable from a macro variable value during the execution of the DATA step

    • B. 

      To include a macro variable reference in a PROC SQL view

    • C. 

      To access the value of a macro variable during the execution of an SCL program

    • D. 

      All of the above

  • 7. 
    Which of the following correctly creates a macro variable in a PROC SQL step?
    • A. 

      Call symput(daily_fee, put(fee/days, dollar8.);

    • B. 

      %let daily_fee=put(fee/days, dollar8.)

    • C. 

      Select fee/days format=dollar8. into :daily_fee from sasuser.all;

    • D. 

      Select fee/days format=dollar8. into daily_fee from sasuser.all;

  • 8. 
    According to the global symbol table shown here, what value will a reference to &&teach&crs resolve to?
    • A. 

      &TEACH3

    • B. 

      TEACH3

    • C. 

      Forest, Mr. Peter

    • D. 

      None of the above

  • 9. 
    Which of the following statements correctly creates a DATA step variable named Price and assigns to it the value of the macro variabledaily_fee during DATA step execution?
    • A. 

      Price=&daily_fee;

    • B. 

      Price=symget(daily_fee);

    • C. 

      Price=symget(&daily_fee);

    • D. 

      Price=symget("daily_fee");

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

      The SYMPUT routine can be used to create a macro variable during execution of the DATA step or during execution of an SCL program.

    • B. 

      In the DATA step, the SYMPUT routine automatically converts to a character value any numeric value that you attempt to assign as the value of a macro variable.

    • C. 

      PROC SQL automatically converts to a numeric value any macro variable value that you attempt to compare to a numeric value.

    • D. 

      In an SCL program, the SYMPUTN routine can be used to assign a numeric value to a macro variable.

Related Topics
Back to Top Back to top