SAS sqlを使用して、後でレポートを使用および印刷するためのマクロ変数を作成しています。
グループごとにいくつかの要約変数(平均、最小、最大など)を作成しています。
次のコードは最初のグループで機能しますが、グループ2と3のマクロ変数は作成しません。
data scores;
input trt t;
cards;
1 10
1 11
1 12
1 13
2 4
2 5
2 6
2 7
3 9
3 8
3 7
3 6
;
run;
%macro cdi;
%do i = 1 %to 3;
proc sql noprint;
select n(t), nmiss(t), mean(t), std(t), min(t), max(t)
into :n&i, :miss&i, :mean&i, :sd&i, :min&i, :max&i
from scores
where trt = &i;
quit;
%end;
%mend cdi;
%cdi;
***** this call shows the right values ;
%put &n1 &miss1 &mean1 &sd1 &min1 &max1 ;
***** this call produces error (symbolic reference not resolved) ;
%put &n2 &miss2 &mean2 &sd2 &min2 &max2 ;
簡単なものが欠けていると思いますが、まだ見ることができません...