I believe a SQL would become rather cumbersome. Below one way to go.
data have1;
input label $ name $ var $ value;
datalines;
L1 A v1 4
L1 B v1 3
L1 C v1 6
L1 D v1 7
L1 E v1 4
L2 A v1 5
L2 B v1 1
L2 C v1 2
L2 D v1 8
L2 E v1 3
L1 A v2 18
L1 B v2 12
L1 C v2 4
L1 D v2 18
L1 E v2 14
L2 A v2 12
L2 B v2 4
L2 C v2 12
L2 D v2 20
L2 E v2 10
;
data have2;
input label $ var $ stat;
datalines;
L1 v1 0.05
L1 v2 0.01
L2 v1 0.07
L2 v2 0.05
;
proc sort data=have1;
by var name;
run;
proc transpose data=have1 out=have1_trans(drop=_:) ;
by var name;
id label;
var value;
run;
proc sort data=have2;
by var;
run;
proc transpose data=have2 out=have2_trans(drop=_:) ;
by var;
id label;
var stat;
run;
data want;
set have1_trans have2_trans(in=in2);
by var;
rename var=version;
if in2 then name='stat';
run;
... View more