SAS Chapter 9: Introducing Macro Variables

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Moxleyv
M
Moxleyv
Community Contributor
Quizzes Created: 38 | Total Attempts: 21,991
| Attempts: 729 | Questions: 10
Please wait...
Question 1 / 10
0 %
0/100
Score 0/100
1. Macro character functions

Explanation

Macro character functions such as %UPCASE and %SUBSTR enable you to perform character manipulations on your macro variable values.

Submit
Please wait...
About This Quiz
SAS Quizzes & Trivia

This SAS Chapter 9 quiz focuses on macro variables, testing understanding through questions on their creation, manipulation, and error handling. It's designed to enhance proficiency in using SAS... see morefor dynamic data processing and reporting. see less

2. Which of the following statements is false?

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.

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

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.

Submit
4. Which statement will create a macro variable named location that has the value 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.

Submit
5. 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?

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.

Submit
6. What value will these statements assign to the macro variable reptitle:
%let area = "Southeast";
%let reptitle = *   Sales Report for &area 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.

Submit
7. The four types of tokens that SAS recognizes are

Explanation

The word scanner recognizes four types of tokens. Expressions are not a type of token.

Submit
8. 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;

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.

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

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.

Submit
10. 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?

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.

Submit
View My Results

Quiz Review Timeline (Updated): Jan 30, 2024 +

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
Cancel
  • All
    All (10)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
Macro character functions
Which of the following statements is false?
Assuming that you began your SAS session today, which of the following...
Which statement will create a macro variable...
Which of the following statements will generate an error message while...
What value will these statements assign to the macro...
The four types of tokens that SAS recognizes are
What are the resulting values for the macro variables that are defined...
Which of the following correctly produces a title in which the current...
Which of the following statements will generate an error message while...
Alert!

Advertisement