Hi all, I try to use these code, including ods layout, proc greplay and proc template, to combine two graphs made by proc sgplot into a png file. However, I couldn't reach this aim (see photo). Any help appreciated. data First_image;
input age sensitivity_2 specificity_2 youden_2;
datalines;
21 1 0 0
25 1 0.0625 0.0625
25 1 0.1875 0.1875
28 1 0.25 0.25
30 1 0.3125 0.3125
33 1 0.375 0.375
35 1 0.4375 0.4375
36 1 0.5 0.5
37 1 0.5625 0.5625
39 0.9375 0.625 0.5625
39 0.9375 0.75 0.6875
41 0.9375 0.8125 0.75
41 0.875 0.8125 0.6875
43 0.8125 0.8125 0.625
47 0.8125 0.875 0.6875
49 0.75 0.875 0.625
50 0.6875 0.875 0.5625
52 0.625 0.875 0.5
55 0.5 0.9375 0.4375
57 0.375 1 0.375
61 0.3125 1 0.3125
61 0.25 1 0.25
61 0.1875 1 0.1875
62 0.125 1 0.125
62 0.0625 1 0.0625
62 0 1 0
64 0 1 0
70 0 1 0
75 0 1 0
77 0 1 0
79 0 1 0
81 0 1 0
;run;
data Second_image;
input disease age;
datalines;
0 50
0 39
0 21
0 61
0 30
0 35
0 25
0 41
0 43
0 36
0 37
0 25
0 41
0 62
0 28
0 33
1 52
1 49
1 47
1 62
1 55
1 70
1 75
1 77
1 81
1 64
1 62
1 39
1 61
1 61
1 57
1 79
;run;
ods graphics / reset=index imagefmt=png width=800px height=350px imagename="First_image";
proc sgplot data=First_image ;
series x=age y=sensitivity_2 / lineattrs = (color=black pattern=1 thickness = 2 ) name="s1" legendlabel = 'Sensitivity' ;
series x=age y=specificity_2 / lineattrs = (color=black pattern=26 thickness = 2) name="s2" legendlabel = "Specificity";
series x=age y=youden_2 / lineattrs = (color=red pattern=41 thickness = 2) name="s3" legendlabel = "Youden's index";
xaxis display=(nolabel) valueattrs=(size=12) fitpolicy=rotate labelattrs=(size=14) values=(21 to 81 by 3);
yaxis label="Proportion" labelattrs=(size=12) valueattrs=(size=14) values=(0 to 1.0 by 0.1);
keylegend "s1" "s2" "s3" / title="Association of sensitivity with specificity as a function of age" titleattrs=(color=black size=12) valueattrs=(size=10);
refline 45.671 / axis=x lineattrs=(pattern=33 color=gray thickness=2) label="Cut Point = 45.671" labelattrs=(size=11) labelloc=inside labelpos=min ;
run;
ods graphics off; footnote1;footnote2;footnote3;
ods graphics/ reset=index imagefmt=png width=800px height=150px imagename="Second_image" ;
proc sgplot data=Second_image noautolegend;
hbox age/ category=disease boxwidth=0.4 nooutliers;
scatter x=age y=disease / jitter transparency=0.5
markerattrs=(color=red symbol=circlefilled);
xaxis display=(nolabel) discreteorder=data;
xaxis label="Age" labelattrs=(size=15) valueattrs=(size=12) values=(21 to 81 by 3) ;
yaxis label='Y axis name' labelattrs=(size=15) valueattrs=(size=12) discreteorder=data reverse;
format disease diseasefmt.;
refline 45.671 / axis=x lineattrs=(pattern=33 color=gray thickness=2) label="Cut Point = 45.671" labelattrs=(size=11) labelloc=inside labelpos=min ;
run;
ods graphics off;
/*=========================================*/
ods _all_ close;
ods listing gpath="c:\sasabc" dpi=300;
ods graphics on/ reset=index imagefmt=png imagename="me";
ods layout start width=840px height=550px ;
ods region x=20px y=20px width=800px height=350px;
proc sgplot data=First_image;
series x=age y=sensitivity_2 / lineattrs = (color=black pattern=1 thickness = 2 ) name="s1" legendlabel = 'Sensitivity' ;
series x=age y=specificity_2 / lineattrs = (color=black pattern=26 thickness = 2) name="s2" legendlabel = "Specificity";
series x=age y=youden_2 / lineattrs = (color=red pattern=41 thickness = 2) name="s3" legendlabel = "Youden's index";
xaxis display=(nolabel) valueattrs=(size=12) fitpolicy=rotate labelattrs=(size=14) values=(21 to 81 by 3);
yaxis label="Proportion" labelattrs=(size=12) valueattrs=(size=14) values=(0 to 1.0 by 0.1);
keylegend "s1" "s2" "s3" / title="Association of sensitivity with specificity as a function of age" titleattrs=(color=black size=12) valueattrs=(size=10);
refline 45.671 / axis=x lineattrs=(pattern=33 color=gray thickness=2) label="Cut Point = 45.671" labelattrs=(size=11) labelloc=inside labelpos=min ;
run;
ods region x=20px y=380px width=800px height=150px;
proc sgplot data=Second_image noautolegend ;
hbox age/ category=disease boxwidth=0.4 nooutliers;
scatter x=age y=disease / jitter transparency=0.5
markerattrs=(color=red symbol=circlefilled);
xaxis display=(nolabel) discreteorder=data;
xaxis label="Age" labelattrs=(size=15) valueattrs=(size=12) values=(21 to 81 by 3) ;
yaxis label='Y axis' labelattrs=(size=15) valueattrs=(size=12) discreteorder=data reverse;
refline 45.671 / axis=x lineattrs=(pattern=33 color=gray thickness=2) label="Cut Point = 45.671" labelattrs=(size=11) labelloc=inside labelpos=min ;
run;
ods layout end;
title;
ods graphics off;ods listing close;
... View more