Multiple choice technology programming languages

The following SAS program is submitted: data work.new; length word $7; amount = 7; if amount = 5 then word = 'CAT'; else if amount = 7 then word = 'DOG'; else word = 'NONE!!!'; amount = 5; run; Which one of the following represents the values of the AMOUNT and WORD variables?

  1. amount word ------ 5 DOG

  2. amount word ------ 5 CAT

  3. amount word ------ 7 DOG

  4. amount word ------ 7 ' ' (missing character value)

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The IF-ELSE structure executes sequentially. Since amount is initialized to 7, the condition 'amount = 5' is false, but 'amount = 7' is true, so word becomes 'DOG'. The later assignment 'amount = 5' only changes the amount variable, not word. The final values are amount=5 and word='DOG'.