The following SAS program Is submittad:
data work.sales;
do year = 1 to 5;
do month=1 to 12;
x+1;
output
end;
end;
run;
How many observations are written the WORK.SALES data set?
A. 0
B. 1
C. 5
D. 60
정답은 D입니다.
프로그램을 수행했을때 WORK.SALES 데이터셋의 관측치는 몇 개인가를 묻는 문제입니다.
output 위치에 따라 답이 달라집니다.
이 문제에서는 x+1 식 밑에 바로 output이 위치하는데요,
이럴 경우 x=1부터 year(5)*month(12) = 60 까지 출력이됩니다.
즉, 60개의 관측치가 나오게 됩니다.
60개의 관측값 출력
data work.sales;
do year = 1 to 5;
do month=1 to 12;
x+1;
output;
end;
end;
run;
5개의 관측값 출력
data work.sales;
do year = 1 to 5;
do month=1 to 12;
x+1;
end;
output;
end;
run;
1개의 관측값 출력
data work.sales;
do year = 1 to 5;
do month=1 to 12;
x+1;
end;
end;
output;
run;