Not the simplest thing for a beginner, but not overly complex either.
This should do what you want.
[pre]
data RR1;
input CODE A1 A2 A3;
cards;
1 1 0.2 0.4
1 0.8 0.2 0.4
1 0.8 0.2 0.3
1 0.9 0.2 0.4
data RR2;
input CODE A1 A2 A3 A4;
cards;
2 1 0.2 0.4 0.2
2 0.8 0.1 0.4 0.1
2 0.9 0.2 0.4 0.1
2 0.9 0.2 0.4 0.1
data RR3;
input CODE A2 A3 A5;
cards;
3 0.2 0.4 0.5
3 0.2 0.3 0.6
3 0.3 0.3 0.5
3 0.2 0.4 0.5
run;
data T/view=T; * group all tables into one;
set
%macro t;
%do i=1 %to 3;
RR&i
%end;
%mend;
%t
;
proc summary data=T nway noprint; * derive variances, means and freqs;
class CODE;
var A1-A5;
output out=T_SUM var= mean= /autoname;
run;
data VARIANCE
SD;
set T_SUM;
array _A(5); * create an array to store final columns;
do I=1 to 5; * store variances into array;
_A[ I]=input(VVALUEX('A'||compress(put(I,1.))||'_VAR'),32.);
end;
output VARIANCE; * output variances;
do I=1 to 5; * derive new value=variance*df/mean;
_A[ I]=input(VVALUEX('A'||compress(put(I,1.))||'_VAR'),32.)
*(_FREQ_-1)
/input(VVALUEX('A'||compress(put(I,1.))||'_MEAN'),32.);
end;
output SD; * output squared deviations;
keep CODE _A: ; * only keep code and array elements in output tables;
run;
[/pre]
You'll hopefully learn a few things by tweaking this code to suit your exact needs.