A00-231 practice question 3 of 10
Given the following SAS data set WORK.TOYS: Product Group Price --------- ----------- ----- Cards Indoors 9.99 Marbles Indoors 8.99 Drum Instruments…
Full set: 36 questionsThe DATA step code contains two separate conditional blocks. The first is an IF statement, and the second is an IF-ELSE IF structure. SAS evaluates these blocks sequentially for each row. For the 'Hula-Hoop' observation (Price=12.99, Group="Outdoors"):
1. if Group="Outdoors" then PriceGp="C"; is TRUE. PriceGp is set to 'C'.
2. if Price ge 12.99 then PriceGp="A"; is also TRUE. PriceGp is overwritten and set to 'A'. The subsequent ELSE IF is skipped. The final value is 'A'. For the 'Ball' observation (Price=8.49, Group="Outdoors"):
1. if Group="Outdoors" then PriceGp="C"; is TRUE. PriceGp is set to 'C'.
2. if Price ge 12.99 then PriceGp="A"; is FALSE.
3. else if Price ge 8.99 then PriceGp="B"; is also FALSE. The value 'C' assigned in the first step remains.
A. Incorrect. The value for Ball is 'C' because the first IF condition is met and is not subsequently changed.
C. Incorrect. The value for Hula-Hoop is 'A' due to the overwrite, and the value for Ball is 'C', not a missing value.
D. Incorrect. The value for Hula-Hoop is 'A' because the second IF statement's condition is true, overwriting the initial 'C' value.
1. SAS Institute Inc. (2020). SAS® 9.4 Statements: Reference, Fifth Edition.
Section: "IF-THEN/ELSE Statement"
Details: The documentation explains that a simple IF-THEN statement is evaluated independently. The code in the question contains a standalone IF-THEN followed by a separate IF-THEN/ELSE construct. SAS executes these sequentially. For the 'Hula-Hoop' record, the first IF assigns a value, and the second IF evaluates its own condition and overwrites that value.
2. University of California, Los Angeles (UCLA), Institute for Digital Research and Education (IDRE). SAS Learning Module: Introduction to the DATA Step.
Section: "Conditional Statements: if-then-else"
Details: This resource clarifies that SAS processes a DATA step one observation at a time, executing statements from top to bottom. It emphasizes the distinction between a series of independent IF statements (where multiple can be true and execute) and a single IF-ELSE IF-ELSE chain (where only the first true condition's action is performed). The question's code demonstrates this sequential execution and variable overwriting.
3. Delwiche, L. D., & Slaughter, S. J. (2012). The Little SAS Book: A Primer, Fifth Edition. SAS Institute.
Chapter 3, Section 3.5: "Using IF-THEN Statements"
Details: This official SAS publication explains that when using a series of IF-THEN statements (without ELSE), SAS evaluates each IF expression independently. This principle directly applies to the question, where the first IF and the second IF are separate logical checks, allowing the second to modify the result of the first.
Keep practicing
Take the free A00-231 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
