Dear Friends
I would like to insert multiple graphs into a single image file.
I'm trying to learn template and sgrender .... but it is quite hostile for me!
Can anybody help me?
Tks in advance!
I attach also the codes I used to create each single graph.
(up to now, I have to put them all together on photoshop...)
proc sgplot data=survivalplotdata;
step x=time y=survival / lineattrs=(pattern=solid thickness=2);
xaxistable AtRisk / x=tAtRisk location=inside valueattrs=(size=10)
label='Patients at risk' labelattrs=(weight=bold);
yaxis min=0 label='Probability'
labelattrs=(weight=bold);
xaxis label='Years' labelattrs=(weight=bold);
Title 'Actuarial survival';
title2 'with patients at risk';
run;
proc sgplot data=cif_cvm;
step x=Int_FU_Death y=CIF / lineattrs=(pattern=solid thickness=2);
xaxistable AtRisk / x=tAtRisk location=inside valueattrs=(size=10)
label='Soggetti a rischio' labelattrs=(weight=bold);
yaxis max=0.20 label='CIF estimate'
labelattrs=(weight=bold);
xaxis label='Years' labelattrs=(weight=bold);
Title 'Cumulative incidence function of CV mortality';
title2 'with patients at risk';
run;
proc sgplot data=cif_m3;
step x=Int_Fu_M3_Redo y=CIF / lineattrs=(pattern=solid thickness=2);
xaxistable AtRisk / x=tAtRisk location=inside valueattrs=(size=10)
label='Patients at risk' labelattrs=(weight=bold);
yaxis max=0.20 label='CIF estimate'
labelattrs=(weight=bold);
xaxis label='Years' labelattrs=(weight=bold);
Title 'Cumulative incidence function of MR ≥3+';
title2 'with patients at risk';
run;
proc sgplot data=cif_redo;
step x=Int_Fu_M3_Redo y=CIF / lineattrs=(pattern=solid thickness=2);
xaxistable AtRisk / x=tAtRisk location=inside valueattrs=(size=10)
label='Patients at risk' labelattrs=(weight=bold);
yaxis max=0.20 label='Cumulative incidence function'
labelattrs=(weight=bold);
xaxis label='Years' labelattrs=(weight=bold);
Title 'Cumulative incidence function of reoperation';
title2 'with patients at risk';
run;
Most of the approaches to single image will rely on a single data set to allow the procedure to generate image.
Since your plots appear similar I would suspect one approach would be to
1) get the same x y variable names in each set
2) combine the data adding a variable to indicate which set each record comes from
3) create a custom format to display the text for the Title statement as the values of a format for the data set indicator variable
4) use SGPANEL with the combined data, use a PANELBY statement using the data set indicator variable with desired options,
options would likely be Rows=2 Columns=2 ONEPANEL if you want a 2 by 2 layout.
5) use COLAXISTABLE instead of xaxistable
6) a COLAXIS statement that looks pretty similar to your XAXIS statement.
use the custom format for the dataset indicator variable. That should become the label for each section of the panel graph.
Combining and renaming the data is not that difficult. Below is a generic example:
data want ; set have1 (in=in1 rename=(abc=pdq) ) have2 (in=in2 rename=(xyz=pdq) ) have3 (in=in3 rename=(nom=pdq) ) have4 (in=in4 rename=(bad=pdq) ) ; indicator = sum(in1*1,in2*2,in3*3,in4*4); run;
The IN= option creates a temporary data set that has a value of 1 when the current data record is from that data set, 0 otherwise.
The indicator uses the 0/1 information to create a variable with values from 1 to 4.
If this were my data I would likely have a Title that was something about "Patients at Risk" and only the first part of your current titles would go into the format.
Dear Reeza,
I got the template from TMPLOUT= option.
My question now is:
How could I join together 4 template codes from 4 different dataset files?
Most of the approaches to single image will rely on a single data set to allow the procedure to generate image.
Since your plots appear similar I would suspect one approach would be to
1) get the same x y variable names in each set
2) combine the data adding a variable to indicate which set each record comes from
3) create a custom format to display the text for the Title statement as the values of a format for the data set indicator variable
4) use SGPANEL with the combined data, use a PANELBY statement using the data set indicator variable with desired options,
options would likely be Rows=2 Columns=2 ONEPANEL if you want a 2 by 2 layout.
5) use COLAXISTABLE instead of xaxistable
6) a COLAXIS statement that looks pretty similar to your XAXIS statement.
use the custom format for the dataset indicator variable. That should become the label for each section of the panel graph.
Combining and renaming the data is not that difficult. Below is a generic example:
data want ; set have1 (in=in1 rename=(abc=pdq) ) have2 (in=in2 rename=(xyz=pdq) ) have3 (in=in3 rename=(nom=pdq) ) have4 (in=in4 rename=(bad=pdq) ) ; indicator = sum(in1*1,in2*2,in3*3,in4*4); run;
The IN= option creates a temporary data set that has a value of 1 when the current data record is from that data set, 0 otherwise.
The indicator uses the 0/1 information to create a variable with values from 1 to 4.
If this were my data I would likely have a Title that was something about "Patients at Risk" and only the first part of your current titles would go into the format.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.