Multiple choice technology programming languages

data temp; length y $5; x=4; if x=4 then y='four'; else if x=7 then y='seven'; x=7; run; What would be the value of X and Y in the dataset temp?

  1. X=4 and Y= ‘seven’

  2. X=7 and Y=’seven’

  3. X=7 and Y=’four’

  4. X=4 and Y=’four’

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

In SAS DATA step logic, the assignment statements execute sequentially. When x=4, the condition 'if x=4' is true (using single = for comparison in SAS), so y='four'. The ELSE IF never executes. Later, x is reassigned to 7, but y remains 'four' - the IF/ELSE doesn't re-evaluate. Final values: x=7, y='four'.