In the data set Work.Invest, what would be the stored value for Year?
data work.invest; do year=1990 to 2004; capital+5000; capital+(capital*.10); end; run;
The correct ans given in the SAS base prep guide is d.2005.
In the below question the stored value is given as 2004. Which of the following statements is false regarding the program shown below?
data work.invest; do year=1990 to 2004; capital+5000; capital+(capital*.10); output; end; run;
DATA
step.DO loop
performs 15 iterations.The correct answer for this is b.2005. (identify the false statement is the question).
Key concepts:
In the first question, that means at the end of the loop, it increments to 2005, goes to the DO statement and says STOP because the DO condition is not met. At the end of the data step the output is generated with the counter at Year=2005.
In the second question because the OUTPUT statement is before the end of the counter so the value output is Year=2004. Additionally the output statement will generate a row for each value of Year, such that the 'stored value' isn't a good question because there will be rows of Year=1990 to 2004 in the output data set.