<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to combine two graph made by proc sgplot to one graph? in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/How-to-combine-two-graph-made-by-proc-sgplot-to-one-graph/m-p/559955#M18173</link>
    <description>&lt;P&gt;Thank you for your reply. I still can't draw the merged picture. I will use photoshop for the time being. In addition,&amp;nbsp; I will find time to study proc template and proc sgrender.&lt;/P&gt;</description>
    <pubDate>Sun, 19 May 2019 14:02:04 GMT</pubDate>
    <dc:creator>Cingchih</dc:creator>
    <dc:date>2019-05-19T14:02:04Z</dc:date>
    <item>
      <title>How to combine two graph made by proc sgplot to one graph?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-combine-two-graph-made-by-proc-sgplot-to-one-graph/m-p/558651#M18145</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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).&lt;/P&gt;&lt;P&gt;Any help appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="S__17752083.jpg" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/29512i7A1A74117E808EFD/image-size/large?v=v2&amp;amp;px=999" role="button" title="S__17752083.jpg" alt="S__17752083.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;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;&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2019 15:10:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-combine-two-graph-made-by-proc-sgplot-to-one-graph/m-p/558651#M18145</guid>
      <dc:creator>Cingchih</dc:creator>
      <dc:date>2019-05-14T15:10:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine two graph made by proc sgplot to one graph?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-combine-two-graph-made-by-proc-sgplot-to-one-graph/m-p/558687#M18147</link>
      <description>&lt;P&gt;GREPLAY is only for device based graphics such as generated by Procs Gplot or Gchart. If the Proc Template code you mention was just to generate GREPLAY areas then that would not help.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc Template is also used for the Graphics Template Language. Which has an extremely large number of options and ways to combine graphs.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/kb/35/177.html" target="_blank"&gt;http://support.sas.com/kb/35/177.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Has an example of using Proc Template GTL code to create three different types of graphs into a single image.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The full code tab has the program code and is commented to show which bits of code generate with parts of the graph as shown on the results tab of the link.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;HOWEVER: You &lt;STRONG&gt;must&lt;/STRONG&gt; place all of the data into a single data set.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2019 16:30:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-combine-two-graph-made-by-proc-sgplot-to-one-graph/m-p/558687#M18147</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2019-05-14T16:30:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine two graph made by proc sgplot to one graph?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-combine-two-graph-made-by-proc-sgplot-to-one-graph/m-p/558695#M18148</link>
      <description>If you end up need GTL, which it seems like you do, PROC SGPLOT has a TMPLOUT (sp?) that will generate the GTL code for you behind so you can more easily migrate it to GTL.</description>
      <pubDate>Tue, 14 May 2019 16:51:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-combine-two-graph-made-by-proc-sgplot-to-one-graph/m-p/558695#M18148</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2019-05-14T16:51:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine two graph made by proc sgplot to one graph?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-combine-two-graph-made-by-proc-sgplot-to-one-graph/m-p/559451#M18169</link>
      <description>&lt;P&gt;One way to do it would be via "brute force" by annotating the 2 graphs onto a third (blank) graph...&lt;/P&gt;
&lt;P&gt;(my code below is very 'rough' - you'd probably want to refine it a bit)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;/* 
Set your current-working-directory (to read/write files), if you need to ...
%let rc=%sysfunc(dlgcdir('c:\someplace\public_html')); 
*/
filename odsout '.';

data First_image;
infile datalines pad truncover dlm='09'x;
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;
infile datalines pad truncover dlm='09'x;
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 LISTING CLOSE;
ODS HTML path=odsout body="First_Image.htm" style=htmlblue;
ods graphics / imagefmt=png imagename="First_Image" width=800px height=350px noborder;

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;

quit;
ODS _all_ CLOSE;
ODS LISTING;


ODS LISTING CLOSE;
ODS HTML path=odsout body="Second_Image.htm" style=htmlblue;
ods graphics / imagefmt=png imagename="Second_Image" width=800px height=150px noborder;

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;

quit;
ODS _all_ CLOSE;
ODS LISTING;



data anno1;
length function widthunit image $20;
layer='front';
function='image'; 
anchor='bottomleft'; 
x1space='graphpercent';
y1space='graphpercent';
x1=(20/840)*100; y1=(180/550)*100;
width=(800/840)*100; widthunit='percent'; 
height=(350/550)*100; heightunit='percent'; 
imagescale='tile';
image='First_Image.png';
run;

data anno2;
length function widthunit image $20;
layer='front';
function='image';
anchor='bottomleft'; 
x1space='graphpercent';
y1space='graphpercent';
x1=(20/840)*100; y1=(20/550)*100;
width=(800/840)*100; widthunit='percent';
height=(150/550)*100; heightunit='percent';
imagescale='tile';
image='Second_Image.png';
run;

data anno_all; set anno1 anno2;
run;

ODS LISTING CLOSE;
ODS HTML path=odsout body="combined.htm" style=htmlblue;
ods graphics / imagefmt=png imagename="combined" width=840px height=550px noborder;

/* generate a blank graph, and annotate the two graphs in it */
data fake_data;
x=50; y=50;
run;
proc sgplot data=fake_data noborder sganno=anno_all;
scatter x=x y=y / markerattrs=(color=white);
xaxis display=(nolabel novalues noticks noline) values=(0 to 100 by 20);
yaxis display=(nolabel novalues noticks noline) values=(0 to 100 by 20);
run;

quit;
ODS _all_ CLOSE;
ODS LISTING;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="combined.png" style="width: 947px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/29581i4D5C61BB6DD3BB5A/image-dimensions/947x620?v=v2" width="947" height="620" role="button" title="combined.png" alt="combined.png" /&gt;&lt;/span&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 16 May 2019 18:53:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-combine-two-graph-made-by-proc-sgplot-to-one-graph/m-p/559451#M18169</guid>
      <dc:creator>GraphGuy</dc:creator>
      <dc:date>2019-05-16T18:53:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine two graph made by proc sgplot to one graph?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-combine-two-graph-made-by-proc-sgplot-to-one-graph/m-p/559955#M18173</link>
      <description>&lt;P&gt;Thank you for your reply. I still can't draw the merged picture. I will use photoshop for the time being. In addition,&amp;nbsp; I will find time to study proc template and proc sgrender.&lt;/P&gt;</description>
      <pubDate>Sun, 19 May 2019 14:02:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-combine-two-graph-made-by-proc-sgplot-to-one-graph/m-p/559955#M18173</guid>
      <dc:creator>Cingchih</dc:creator>
      <dc:date>2019-05-19T14:02:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine two graph made by proc sgplot to one graph?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-combine-two-graph-made-by-proc-sgplot-to-one-graph/m-p/560108#M18174</link>
      <description>&lt;P&gt;Are you getting errors when you try to run the code?&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2019 12:20:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-combine-two-graph-made-by-proc-sgplot-to-one-graph/m-p/560108#M18174</guid>
      <dc:creator>GraphGuy</dc:creator>
      <dc:date>2019-05-20T12:20:20Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine two graph made by proc sgplot to one graph?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-combine-two-graph-made-by-proc-sgplot-to-one-graph/m-p/560119#M18175</link>
      <description>&lt;P&gt;I tried to draw the combined image via the code again, and I finally succeed tonight. Thank you.&lt;/P&gt;&lt;P&gt;I have two new questions described in the picture below.&amp;nbsp;&lt;SPAN&gt;Thanks in advance!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Image 011.png" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/29644i98A19AFCE4D8E33B/image-size/large?v=v2&amp;amp;px=999" role="button" title="Image 011.png" alt="Image 011.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2019 13:08:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-combine-two-graph-made-by-proc-sgplot-to-one-graph/m-p/560119#M18175</guid>
      <dc:creator>Cingchih</dc:creator>
      <dc:date>2019-05-20T13:08:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine two graph made by proc sgplot to one graph?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-combine-two-graph-made-by-proc-sgplot-to-one-graph/m-p/560129#M18176</link>
      <description>&lt;P&gt;x1, y1 is the location of the bottom/left corner of the annotated image, in the final (combined) png ... as a percentage.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If the bottom annotated graph is 20 pixels from the bottom edge, and the final png is 550 pixels tall, then y1 is (20/550)*100 ... which is 3.63%&lt;/P&gt;</description>
      <pubDate>Mon, 20 May 2019 13:37:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-combine-two-graph-made-by-proc-sgplot-to-one-graph/m-p/560129#M18176</guid>
      <dc:creator>GraphGuy</dc:creator>
      <dc:date>2019-05-20T13:37:29Z</dc:date>
    </item>
    <item>
      <title>Re: How to combine two graph made by proc sgplot to one graph?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-combine-two-graph-made-by-proc-sgplot-to-one-graph/m-p/560131#M18177</link>
      <description>I understand it. Thank you very much. ^____^</description>
      <pubDate>Mon, 20 May 2019 13:40:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-combine-two-graph-made-by-proc-sgplot-to-one-graph/m-p/560131#M18177</guid>
      <dc:creator>Cingchih</dc:creator>
      <dc:date>2019-05-20T13:40:31Z</dc:date>
    </item>
  </channel>
</rss>

