一个有用的SAS code,用于在同一空间里画两个分布曲线。
data test;
drop i;
do group='A','B';
do i=1 to 10;
x=20+ 8*rannor(12345);
output;
end;
end;
run;
proc print; run;
proc transpose data=test out=test2;
by group;
var x;
run;
proc transpose data=test2 out=test3(drop=_name_);
id group;
run;
proc print; run;
ods listing close;
ods html;
proc sgplot data=test3;
density A / lineattrs=(color=red pattern=1) legendlabel='A';
density B / lineattrs=(color=blue pattern=2) legendlabel='B';
xaxis label='Normal Curves';
run;
ods html close;
ods listing;
o****o 发帖数: 8077
2
why do u have to transpose the data twice? you can simply do:
data test3;
merge test(where=(group='A') rename=(X=A))
test(where=(group='B') rename=(X=B))
;
run;