Multiple choice technology programming languages

Data X; do i = 1 to 10; i = i*3; output; end; output; Run; How many observations will be there in Dataset X and what will be the value of I at last Observation?

  1. No. of Observations = 2 I = 12

  2. No. of Observations = 10 I = 30

  3. No. of Observations = 4 I = 12

  4. No. of Observations = 3 I = 13

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

The DO loop starts at i=1. Inside, i=i*3 makes i=3 on first iteration. After OUTPUT and END, loop checks i <= 10. Next iteration i becomes 6 (3*3), then 9 (6*3 would be 18 > 10, so only 3 iterations). Final OUTPUT after loop is 4th observation. Final i=9+3=12 (from last multiplication) + 1 from loop increment.