SAS Chapter 9: Introducing Macro Variables

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Moxleyv
M
Moxleyv
Community Contributor
Quizzes Created: 38 | Total Attempts: 21,441
Questions: 10 | Attempts: 710

SettingsSettingsSettings
SAS Quizzes & Trivia

Practice for the SAS advance certification exam


Questions and Answers
  • 1. 

    Which of the following statements is false?

    • A.

      A macro variable can be defined and referenced anywhere in a SAS program except within data lines.

    • B.

      Macro variables are always user-defined, and their values remain constant until they are changed by the user.

    • C.

      Macro variables are text strings that are independent of SAS data sets.

    • D.

      The values of macro variables can be up to 65,534 characters long.

    Correct Answer
    B. Macro variables are always user-defined, and their values remain constant until they are changed by the user.
    Explanation
    Macro variables are always text strings that are independent of SAS data sets. The value of a macro variable can be up to 65,534 characters long, and the name of a macro variable can be up to 32 characters long. A macro variable can be defined or referenced anywhere in a SAS program except within data lines. There are two types of macro variables: automatic and user-defined.

    Rate this question:

  • 2. 

    Which of the following statements will generate an error message while trying to display the value of the macro variable month in the SAS log?

    • A.

      Title "Total Sales for '&month' ";

    • B.

      Title "Total Sales for 'month'";

    • C.

      Title "Total Sales for &month";

    • D.

      Title Total Sales for "&month";

    Correct Answer
    A. Title "Total Sales for '&month' ";
    Explanation
    The statement that will generate an error message while trying to display the value of the macro variable month in the SAS log is title "Total Sales for 'month'";. This is because ‘month’ is enclosed in single quotes, which means SAS will interpret it as a literal string, not a macro variable. The other three statements correctly reference month as a macro variable, either enclosed in double quotes or not enclosed in quotes at all.

    Rate this question:

  • 3. 

    Which of the following statements will generate an error message while trying to display the value of the macro variable month in the SAS log?

    • A.

      Options &month;

    • B.

      %PUT &month;

    • C.

      Options symbolgen;

    • D.

      %PUT the macro variable MONTH has the value &month.;

    Correct Answer
    A. Options &month;
    Explanation
    There are two ways to display the value of a macro variable in the SAS log: you can turn on the SYMBOLGEN system option to list the values of all macro variables that are used, or you can use the %PUT statement to write specific text, including macro variable values, to the log.

    Rate this question:

  • 4. 

    Which statement will create a macro variable named location that has the value storage?

    • A.

      &let location = storage;

    • B.

      Let &location = storage;

    • C.

      %let location = "storage";

    • D.

      %let location = storage;

    Correct Answer
    D. %let location = storage;
    Explanation
    You use the %LET statement to define a macro variable. You do not need to enclose the value in quotation marks. If you do include quotation marks in the assigned value for a macro variable, the quotation marks will be stored as part of the value.

    Rate this question:

  • 5. 

    What value will these statements assign to the macro variable reptitle: %let area = "Southeast"; %let reptitle = * Sales Report for &area Area *;

    • A.

      Sales Report for Southeast Area

    • B.

      Sales Report for "Southeast" Area

    • C.

      *Sales Report for "Southeast" Area*

    • D.

      * Sales Report for "Southeast" Area *

    Correct Answer
    D. * Sales Report for "Southeast" Area *
    Explanation
    Macro variables are stored as character strings. Quotation marks and most special characters are stored exactly as they are assigned, but leading blanks are stripped from assigned values. You can also include references to other macro variables within %LET statements.

    Rate this question:

  • 6. 

    Assuming that you began your SAS session today, which of the following statements correctly sets the macro variable currdate to today's date:

    • A.

      %let currdate = %sysfunc(today(), worddate.);

    • B.

      %let currdate = &sysdate9;

    • C.

      %let currdate = %sysfunc(date());

    • D.

      All of the above

    Correct Answer
    D. All of the above
    Explanation
    SYSDATE9 is an automatic macro variable that stores the date that your SAS session began in ddmmmyyyy format. You can use the %SYSFUNC function along with any DATA step function, so both the TODAY() function and the DATE() function will result in the current date.

    Rate this question:

  • 7. 

    Macro character functions

    • A.

      Can be used to manipulate character strings in macro variable values.

    • B.

      Have the same basic syntax as the corresponding DATA step functions and yield similar results.

    • C.

      All of the above

    • D.

      None of the above

    Correct Answer
    C. All of the above
    Explanation
    Macro character functions such as %UPCASE and %SUBSTR enable you to perform character manipulations on your macro variable values.

    Rate this question:

  • 8. 

    The four types of tokens that SAS recognizes are

    • A.

      Expressions, literals, names, and special characters.

    • B.

      Literals, names, numbers, and special characters.

    • C.

      Expressions, names, numbers, and special characters.

    • D.

      Expressions, literals, numbers, and special characters.

    Correct Answer
    B. Literals, names, numbers, and special characters.
    Explanation
    The word scanner recognizes four types of tokens. Expressions are not a type of token.

    Rate this question:

  • 9. 

    What are the resulting values for the macro variables that are defined here? %let month1 = June; %let month2 = July; %let period1 = &month1&month2; %let period2 = May&month1; %let period3 = &month2.Aug;

    • A.

      month1 June month2 July period1 June July period2 May June period3 July Aug

    • B.

      month1 June month2 July period1 JuneJuly period2 MayJune period3 July.Aug

    • C.

      month1 June month2 July period1 JuneJuly period2 MayJune period3 JulyAug

    • D.

      month1 June month2 July period1 junejuly period2 Mayjune period3 julyaug

    Correct Answer
    C. month1 June month2 July period1 JuneJuly period2 MayJune period3 JulyAug
    Explanation
    You can combine macro variable references with text to create new text strings. If you precede a macro variable with text, the ampersand at the beginning of the macro variable name signals the end of the text and the beginning of a macro variable name. If you want text to follow the macro variable value, you must signal the end of the macro variable name with a period.

    Rate this question:

  • 10. 

    Which of the following correctly produces a title in which the current date is left justified in order to remove extra blanks?

    • A.

      title "Report for %sysfunc(left(%sysfunc(today(),worddate.)))";

    • B.

      title "Report for %sysfunc(left(today(), worddate.))";

    • C.

      title "Report for %sysfunc(left(%qsysfunc(today(), worddate.)))";

    • D.

      title "Report for %left(today(), worddate.))";

    Correct Answer
    C. title "Report for %sysfunc(left(%qsysfunc(today(), worddate.)))";
    Explanation
    You use the %QSYSFUNC function in this case, in order to mask the comma that results from the worddate. format. You must mask this comma since the LEFT() function expects only one argument.

    Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Jan 30, 2024
    Quiz Edited by
    ProProfs Editorial Team
  • Mar 18, 2013
    Quiz Created by
    Moxleyv

Related Topics

Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.