<?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: Side-by-Side SG PLOT saved as png in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Side-by-Side-SG-PLOT-saved-as-png/m-p/807625#M22756</link>
    <description>&lt;P&gt;How about providing definitions for the macro variables that you are using but not explaining.&lt;/P&gt;
&lt;P&gt;Also your HAVE data does not contain one of the variable used in the plot: PHADY.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc SGpanel is intended to place multiple graphs into a single panel, side-by-side or above each other. So might want to consider the procedure used. Panelby variable(s) controls what makes groups of plots.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you really aren't providing a lot of options in your SCATTER perhaps you only need Series with the MARKERS option.&lt;/P&gt;</description>
    <pubDate>Wed, 13 Apr 2022 15:26:43 GMT</pubDate>
    <dc:creator>ballardw</dc:creator>
    <dc:date>2022-04-13T15:26:43Z</dc:date>
    <item>
      <title>Side-by-Side SG PLOT saved as png</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Side-by-Side-SG-PLOT-saved-as-png/m-p/807610#M22755</link>
      <description>&lt;P&gt;I want all these plots to be saved side-by-side in a PNG file. When I run my code, I get 4 individual PNG files saved for each phase.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Macro:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro plot1(i=, T=, T7=);
	proc sgplot data= &amp;amp;dsn. noautolegend;
	 where usubjid= "&amp;amp;id." and paramcd = "&amp;amp;param." and aphase = "&amp;amp;i".;
		series x= phady y= chg;
		scatter x= phady y= chg;
		*styleattrs
		datacontrastcolors= (red blue orange green)
		datalinepatterns= (solid);
		
		%if &amp;amp;T = NA %then %do;
			xaxis min= 1 max= 25 values= (1 6 8) valuesdisplay= ("1" "6" "8") label= "Actual CHMI Day";
			yaxis min= 0 max= 50 values= (-1 to 2.5 by 0.5) label= "Antibody Reactivity (Baseline-adjusted OD^{unicode '2082'x}410)";
		%end;
			%else %do;
				xaxis min= 1 max= 25 values= (1 6 8 &amp;amp;T. &amp;amp;T7.) valuesdisplay= ("1" "6" "8" "T" "T+7") label= "Actual CHMI Day";
				yaxis min= -1 max= 50 values= (-1 to 2.5 by 0.5) label= "Antibody Reactivity (Baseline-adjusted OD410)";	
			%end;	
	run;
%mend;
%macro panel(dsn, id, chmi1, chmi17, chmi2, chmi27, chmi3, chmi37, chmi4, chmi47);
	ods graphics / reset= index width= 9in height= 7in border= no
						imagename= "Fig_immuno_ind_&amp;amp;trt._&amp;amp;id." imagefmt= png; 
	ods layout gridded columns= 4 advance= table;
	title1 "Subject &amp;amp;id."; **try ODS Graphics tool**;

	%plot1(i= CHMI1, T= &amp;amp;chmi1., T7= &amp;amp;chmi17.);
	%plot1(i= CHMI2, T= &amp;amp;chmi2., T7= &amp;amp;chmi27.);
	%plot1(i= CHMI3, T= &amp;amp;chmi3., T7= &amp;amp;chmi37.);
	%plot1(i= CHMI4, T= &amp;amp;chmi4., T7= &amp;amp;chmi47.);

	ods layout end;
%mend;

%let param= IgG; %let trt= IgG&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Mock Data:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
 input usubjid $ phase $ stdy paramcd $ chg trtdy1 trtdy2 @@;
 cards;
A	CHMI1	1	IgG 	-0.794	.	.
A	CHMI1	2	IgG 	-0.854	.	.
A	CHMI1	3	IgG 	-0.822	.	.
A	CHMI1	4	IgG 	-0.724	.	.
A	CHMI1	5	IgG 	-0.765	.	.
A	CHMI1	6	IgG 	-0.721	.	.
A	CHMI1	7	IgG 	-0.605	.	.
A	CHMI1	8	IgG 	-0.557	.	.
A	CHMI1	9	IgG 	-0.421	.	.
A	CHMI2	1	IgG 	0.489	.	.
A	CHMI2	2	IgG 	0.211	.	.
A	CHMI2	3	IgG 	0.089	.	.
A	CHMI2	4	IgG 	-0.121	4	11
A	CHMI2	5	IgG 	-0.150	4	11
A	CHMI2	6	IgG 	-0.268	4	11
A	CHMI2	7	IgG 	-0.279	4	11
A	CHMI2	8	IgG 	-0.226	4	11
A	CHMI2	9	IgG 	-0.112	4	11
A	CHMI2	10	IgG 	-0.025	4	11
A	CHMI2	11	IgG 	-0.079	4	11
A	CHMI3	1	IgG 	-0.014	9	.
A	CHMI3	2	IgG 	-0.028	9	.
A	CHMI3	3	IgG 	-0.112	9	.
A	CHMI3	4	IgG 	-0.186	9	.
A	CHMI3	5	IgG 	-0.101	9	.
A	CHMI3	6	IgG 	-0.026	9	.
A	CHMI3	7	IgG 	0.082	9	.
A	CHMI3	8	IgG 	0.052	9	.
A	CHMI3	9	IgG 	0.106	9	.
A	CHMI3	10	IgG 	0.044	9	.
A	CHMI3	11	IgG 	-0.025	9	.
A	CHMI3	12	IgG 	-0.111	9	.
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2022 14:43:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Side-by-Side-SG-PLOT-saved-as-png/m-p/807610#M22755</guid>
      <dc:creator>mariko5797</dc:creator>
      <dc:date>2022-04-13T14:43:24Z</dc:date>
    </item>
    <item>
      <title>Re: Side-by-Side SG PLOT saved as png</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Side-by-Side-SG-PLOT-saved-as-png/m-p/807625#M22756</link>
      <description>&lt;P&gt;How about providing definitions for the macro variables that you are using but not explaining.&lt;/P&gt;
&lt;P&gt;Also your HAVE data does not contain one of the variable used in the plot: PHADY.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Proc SGpanel is intended to place multiple graphs into a single panel, side-by-side or above each other. So might want to consider the procedure used. Panelby variable(s) controls what makes groups of plots.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since you really aren't providing a lot of options in your SCATTER perhaps you only need Series with the MARKERS option.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2022 15:26:43 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Side-by-Side-SG-PLOT-saved-as-png/m-p/807625#M22756</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-04-13T15:26:43Z</dc:date>
    </item>
    <item>
      <title>Re: Side-by-Side SG PLOT saved as png</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Side-by-Side-SG-PLOT-saved-as-png/m-p/807628#M22757</link>
      <description>&lt;P&gt;If the 4 graphs can share the same axes, I recommend Proc SGpanel.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you want the 4 graphs to be independent, I recommend Proc GReplay, with 4 Proc GPlot's.&lt;/P&gt;
&lt;P&gt;Here's an example of Greplay:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://robslink.com/SAS/democd67/anscombe_quartet.htm" target="_blank"&gt;http://robslink.com/SAS/democd67/anscombe_quartet.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://robslink.com/SAS/democd67/anscombe_quartet.sas" target="_blank"&gt;https://robslink.com/SAS/democd67/anscombe_quartet.sas&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="greplay.png" style="width: 800px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/70355iCCFFFE8202F89805/image-size/large?v=v2&amp;amp;px=999" role="button" title="greplay.png" alt="greplay.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2022 15:42:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Side-by-Side-SG-PLOT-saved-as-png/m-p/807628#M22757</guid>
      <dc:creator>GraphGuy</dc:creator>
      <dc:date>2022-04-13T15:42:30Z</dc:date>
    </item>
    <item>
      <title>Re: Side-by-Side SG PLOT saved as png</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Side-by-Side-SG-PLOT-saved-as-png/m-p/807630#M22758</link>
      <description>&lt;P&gt;Annotations to macro added. PHADY changed to STDY.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;* Plot for Individual CHMI Treatment;
%macro plot1(i=, 	/*CHMI treatment number*/
			 T=, 	/*treatment day*/
 			 T7=	/*7 days post treatment*/
			);
	proc sgplot data= &amp;amp;dsn. noautolegend;
	 where usubjid= "&amp;amp;id." and paramcd = "&amp;amp;param." and aphasen = "&amp;amp;i.";
		series x= stdy y= chg;
		scatter x= stdt y= chg;
		*styleattrs
		datacontrastcolors= (red blue orange green)
		datalinepatterns= (solid);
		
		%if &amp;amp;T = NA %then %do;
			xaxis min= 1 max= 25 values= (1 6 8) valuesdisplay= ("1" "6" "8") label= "Actual CHMI Day";
			yaxis min= 0 max= 50 values= (-1 to 2.5 by 0.5) label= "Antibody Reactivity (Baseline-adjusted OD^{unicode '2082'x}410)";
		%end;
			%else %do;
				xaxis min= 1 max= 25 values= (1 6 8 &amp;amp;T. &amp;amp;T7.) valuesdisplay= ("1" "6" "8" "T" "T+7") label= "Actual CHMI Day";
				yaxis min= -1 max= 50 values= (-1 to 2.5 by 0.5) label= "Antibody Reactivity (Baseline-adjusted OD410)";	
			%end;	
	run;
%mend;

* Plots Side-by-Side for Individual Subjects;
%macro panel(dsn, 				/*input dataset*/
			 id, 				/*subject ID*/
			 chmi1, chmi17, 	/*CHMI 1 treatment day and 7 days post treatment*/
			 chmi2, chmi27, 	/*CHMI 2 treatment day and 7 days post treatment*/
			 chmi3, chmi37, 	/*CHMI 3 treatment day and 7 days post treatment*/
			 chmi4, chmi47		/*CHMI 4 treatment day and 7 days post treatment*/
			);
	ods graphics / reset= index width= 9in height= 7in border= no
						imagename= "Fig_immuno_ind_&amp;amp;trt._&amp;amp;id." imagefmt= png; 
	ods layout gridded columns= 4 advance= table;
	title1 "Subject &amp;amp;id.";

	%plot1(i= CHMI1, T= &amp;amp;chmi1., T7= &amp;amp;chmi17.);
	%plot1(i= CHMI2, T= &amp;amp;chmi2., T7= &amp;amp;chmi27.);
	%plot1(i= CHMI3, T= &amp;amp;chmi3., T7= &amp;amp;chmi37.);
	%plot1(i= CHMI4, T= &amp;amp;chmi4., T7= &amp;amp;chmi47.);

	ods layout end;
%mend;

%let param= IgG; %let trt= IgG; 

%panel(have, A, NA, NA, 4, 11, 9, NA, NA, NA);	
/*Note: subject A only has treatment day available for CHMI 2 and CHMI 3 based on HAVE.TRTDY1*/&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;SGPANEL isn't used since treatment day varies by CHMI. Implementation notes specify non-uniform spacing between CHMI days with treatment day labelled as 'T' and 7-days post treatment labelled as 'T+7'.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2022 15:54:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Side-by-Side-SG-PLOT-saved-as-png/m-p/807630#M22758</guid>
      <dc:creator>mariko5797</dc:creator>
      <dc:date>2022-04-13T15:54:31Z</dc:date>
    </item>
    <item>
      <title>Re: Side-by-Side SG PLOT saved as png</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Side-by-Side-SG-PLOT-saved-as-png/m-p/807631#M22759</link>
      <description>&lt;P&gt;*STDT should be STDY&lt;/P&gt;</description>
      <pubDate>Wed, 13 Apr 2022 15:55:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Side-by-Side-SG-PLOT-saved-as-png/m-p/807631#M22759</guid>
      <dc:creator>mariko5797</dc:creator>
      <dc:date>2022-04-13T15:55:06Z</dc:date>
    </item>
    <item>
      <title>Re: Side-by-Side SG PLOT saved as png</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Side-by-Side-SG-PLOT-saved-as-png/m-p/807637#M22760</link>
      <description>&lt;P&gt;Instead of using ODS HTML, use ODS PRINTER with a printer of PNG. Here is a simple example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%macro plot;
ods region;
proc sgplot data=sashelp.class;
vbar age;
run;
%mend;
ods graphics / width=350px;
ods _all_ close;
ods printer printer=png;
ods layout gridded;
ods layout start columns=2;
%plot;
%plot;
%plot;
%plot;
ods layout end;
ods printer close;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 13 Apr 2022 16:57:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Side-by-Side-SG-PLOT-saved-as-png/m-p/807637#M22760</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2022-04-13T16:57:00Z</dc:date>
    </item>
    <item>
      <title>Re: Side-by-Side SG PLOT saved as png</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Side-by-Side-SG-PLOT-saved-as-png/m-p/807778#M22768</link>
      <description>&lt;P&gt;Or try PROC SGSCATTER .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;data have;
 input usubjid $ phase $ stdy paramcd $ chg trtdy1 trtdy2 @@;
 cards;
A CHMI1 1 IgG  -0.794 . .
A CHMI1 2 IgG  -0.854 . .
A CHMI1 3 IgG  -0.822 . .
A CHMI1 4 IgG  -0.724 . .
A CHMI1 5 IgG  -0.765 . .
A CHMI1 6 IgG  -0.721 . .
A CHMI1 7 IgG  -0.605 . .
A CHMI1 8 IgG  -0.557 . .
A CHMI1 9 IgG  -0.421 . .
A CHMI2 1 IgG  0.489 . .
A CHMI2 2 IgG  0.211 . .
A CHMI2 3 IgG  0.089 . .
A CHMI2 4 IgG  -0.121 4 11
A CHMI2 5 IgG  -0.150 4 11
A CHMI2 6 IgG  -0.268 4 11
A CHMI2 7 IgG  -0.279 4 11
A CHMI2 8 IgG  -0.226 4 11
A CHMI2 9 IgG  -0.112 4 11
A CHMI2 10 IgG  -0.025 4 11
A CHMI2 11 IgG  -0.079 4 11
A CHMI3 1 IgG  -0.014 9 .
A CHMI3 2 IgG  -0.028 9 .
A CHMI3 3 IgG  -0.112 9 .
A CHMI3 4 IgG  -0.186 9 .
A CHMI3 5 IgG  -0.101 9 .
A CHMI3 6 IgG  -0.026 9 .
A CHMI3 7 IgG  0.082 9 .
A CHMI3 8 IgG  0.052 9 .
A CHMI3 9 IgG  0.106 9 .
A CHMI3 10 IgG  0.044 9 .
A CHMI3 11 IgG  -0.025 9 .
A CHMI3 12 IgG  -0.111 9 .
;
run;

data want;
merge have(keep=phase stdy chg where=(phase='CHMI1'))
      have(keep=phase stdy chg where=(phase2='CHMI2') rename=(phase=phase2 chg=ch2))
   have(keep=phase stdy chg where=(phase3='CHMI3') rename=(phase=phase3 chg=ch3)) ;
 by stdy;
run;

proc sgscatter data=want;
plot chg*stdy ch2*stdy ch3*stdy/join;
run;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1649937268713.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/70383iF35472EAACFF9AE6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1649937268713.png" alt="Ksharp_0-1649937268713.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Apr 2022 11:54:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Side-by-Side-SG-PLOT-saved-as-png/m-p/807778#M22768</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2022-04-14T11:54:35Z</dc:date>
    </item>
  </channel>
</rss>

