SAS Chapter 10: Processing Macro Variables At Execution Time

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,992
| Attempts: 357 | Questions: 10
Please wait...
Question 1 / 10
0 %
0/100
Score 0/100
1. In which of the following situations would you use SYMGET rather than a macro variable reference (&macvar)?

Explanation

A macro variable reference (&macvar) is resolved before any SAS language statements are sent to the compiler. The SYMGET function enables you to obtain the value of a macro variable during the execution of a DATA step or a PROC SQL step. The SYMGET function can also be used to obtain the value of a macro variable during the execution of an SCL program.

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

This quiz, titled 'SAS Chapter 10: Processing Macro Variables at Execution Time,' tests knowledge on macro variable processing in SAS. It covers creating, assigning, and referencing macro variables, and differentiating true statements from false regarding macro processing.

Personalize your quiz and earn a certificate with your name on it!
2. Which of the following correctly creates a macro variable in a PROC SQL step?

Explanation

To create a macro variable during the execution of a PROC SQL step, use the INTO clause of the SELECT statement. In the INTO clause, you precede the name of the macro variable with a colon.

Submit
3. Which of the following statements about the resolution of macro variable references is false?

Explanation

If more than four consecutive ampersands precede a name token, rescanning continues from left to right until no more triggers can be resolved. The Forward Re-scan rule describes how the macro processor resolves macro variable references that start with multiple ampersands or with multiple percent signs.

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

Explanation

You can use multiple ampersands to delay the resolution of a macro variable reference. You can also combine macro variable references in order to create new tokens. In this example, the reference &&teach&crs resolves to &teach3 on the first scan. On the next scan, &teach3 resolves to Forest, Mr. Peter.

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

Explanation

To create a macro variable and assign to it a value that is based on the value of a DATA step variable, you use the SYMPUT routine. In the SYMPUT routine, to assign a literal string as a macro variable name, you enclose the literal in quotation marks. To assign a literal string as a value of the macro variable, you enclose the literal in quotation marks.

Submit
6. Which of the following is false?

Explanation

Most macro functions are handled by the macro processor before any SAS language statements in the DATA step are executed. For example, the %LET statement and any macro variable references (&macvar) are passed to the macro processor before the program is compiled. In order to create or update macro variables during DATA step execution, you use the SYMPUT routine.

Submit
7. Which of the following is false?

Explanation

The SYMPUT routine can be used in either the DATA step or in an SCL program. In the DATA step, the SYMPUT routine will perform automatic conversion on numeric values that you attempt to assign as values for macro variables, using the BEST12. format. In an SCL program, you should use the SYMPUTN routine if you want to assign a numeric value as a value for a macro variable. In a PROC SQL step, you need to use the INPUT function in order to convert macro variable values to numeric before you compare them to other numeric values.

Submit
8. The SYMPUT routine cannot

Explanation

The SYMPUT routine enables you to assign a data set variable as the value of a macro variable. You can also use the SYMPUT routine to create a series of related macro variables. Because all macro variable values are character strings, SYMPUT automatically converts any numeric value that you attempt to assign as a value for a macro variable. In an SCL program, you must use SYMPUTN rather than SYMPUT if you are attempting to assign a numeric value to a macro variable.

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

Explanation

You can use multiple ampersands to create an indirect reference when the value of one macro variable is the name of another. If you enclose the DATA step variable name in quotation marks in the SYMPUT routine, the new macro variable will have the same name as the DATA step variable rather than having the DATA step variable's value as a name. Use the SYMGET function to obtain the value of a macro variable during the execution of a DATA step.

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

Explanation

You can use the SYMGET function in an assignment statement to obtain the current value of a macro variable and to assign that value to a DATA step variable. The SYMGET function enables you to obtain the value of a macro variable during execution of a DATA step, a PROC SQL step, or an SCL program.

Submit
View My Results

Quiz Review Timeline (Updated): Mar 17, 2023 +

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

  • Current Version
  • Mar 17, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Mar 18, 2013
    Quiz Created by
    Moxleyv
Cancel
  • All
    All (10)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
In which of the following situations would you use SYMGET rather than...
Which of the following correctly creates a macro variable in a PROC...
Which of the following statements about the resolution of macro...
According to the global symbol table shown here, what value will a...
Which of the following correctly creates a macro variable...
Which of the following is false?
Which of the following is false?
The SYMPUT routine cannot
Which of the following programs correctly creates a series of macro...
Which of the following statements correctly creates a DATA step...
Alert!

Advertisement