<?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 SGPlot n-by-m with varied color ?! in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/How-to-SGPlot-n-by-m-with-varied-color/m-p/974711#M377968</link>
    <description>&lt;P&gt;OK. That is need a some sophisticated skill "DATTRMAP= option" .&lt;/P&gt;
&lt;PRE&gt;options nodate nonumber;
options papersize=(7.35in 5.75in);
options leftmargin="0.001in" rightmargin="0.001in";
options nobyline;

data heart;
set sashelp.heart;
if (weight_status eq '') then weight_status="Unknown";
run;
proc sort data=heart; by weight_status; run;

title "Cholesterol Distribution by Weight Status";


&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;
data dattrmap;
infile cards truncover;
input id $ value :$20. linecolor $  ;
datalines;
x  Normal  red 
x  Overweight  blue 
x  Underweight  green 
;
run;&lt;/STRONG&gt;&lt;/FONT&gt;





ods printer printer=png300 file="bygroups.png" style=normalprinter;
ods layout gridded columns=2 rows=2 advance=bygroup
    column_gutter=0.1in row_gutter=0.1in;
ods graphics / width=3.5in ;
title "#byval1";
proc sgplot data=heart noautolegend uniform=xscale &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt; dattrmap=dattrmap&lt;/STRONG&gt;&lt;/FONT&gt; ;
&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;by weight_status;&lt;/STRONG&gt;&lt;/FONT&gt;
yaxis offsetmin=0.05;
series x=weight y=height /&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt; group=weight_status attrid=x&lt;/STRONG&gt;&lt;/FONT&gt;;
run;
ods layout end;
ods printer close;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1757486117037.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/109844i840D59AAE3D19BE2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1757486117037.png" alt="Ksharp_0-1757486117037.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 10 Sep 2025 06:35:28 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2025-09-10T06:35:28Z</dc:date>
    <item>
      <title>How to SGPlot n-by-m with varied color ?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-SGPlot-n-by-m-with-varied-color/m-p/974567#M377926</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;	ods layout gridded columns=2 rows=3 advance=proc;
	proc sgplot data=ts_pout_xrs1(where=(ind between &amp;amp;stind. and &amp;amp;endind.));
	by xrs_flag1;
	series x=ind y=ts_out /lineattrs=(color=random thickness=2 pattern=solid);  
	refline  &amp;amp;minind./axis=x;
	run;quit;
	ods layout end;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I have&amp;nbsp; time-series summary by xrs_flag1 with 6 groups. Like to plot these 6 into 2-by-3 layout.&lt;/P&gt;
&lt;P&gt;HOWEVER it does not (show up at 1*6 in seq). Also the lines have the same color for all.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How to SGPlot n-by-m with varied color ?!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Sep 2025 06:47:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-SGPlot-n-by-m-with-varied-color/m-p/974567#M377926</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2025-09-09T06:47:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to SGPlot n-by-m with varied color ?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-SGPlot-n-by-m-with-varied-color/m-p/974573#M377932</link>
      <description>&lt;P&gt;Custom graph questions go much better with some example data. Many times a new variable(s) or changes in the data structure are needed to accomplish the desire.&lt;/P&gt;
&lt;P&gt;Best is to provide example data in the form of working data step code and include only the variables related to the question.&lt;/P&gt;
&lt;P&gt;Or use one of the SAS supplied data sets such as SASHELP.Class or SASHELP.CARS.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To show graphs in a 2x3 layout better would likely be Proc SGPanel with your XRS_flag1 variable as the Panelby variable and layout options on the panel by for colums=2 and rows =3 (or vice versa depending, some people reverse the order in discussion).&lt;/P&gt;
&lt;P&gt;The Plot statement would look basically the same but could use a GROUP=XRX_flag1 to get different colors, remove the Color= option from the Lineattrs options.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I might start with something like:&lt;/P&gt;
&lt;PRE&gt;proc sgpanel data=ts_pout_xrs1(where=(ind between &amp;amp;stind. and &amp;amp;endind.));
	panelby xrs_flag1/ onepanel columns=3 ;
	series x=ind y=ts_out / group=xrs_flag1 lineattrs=( thickness=2 pattern=solid);  
	refline  &amp;amp;minind./axis=x;
	run;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Sep 2025 08:02:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-SGPlot-n-by-m-with-varied-color/m-p/974573#M377932</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2025-09-09T08:02:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to SGPlot n-by-m with varied color ?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-SGPlot-n-by-m-with-varied-color/m-p/974577#M377935</link>
      <description>&lt;P&gt;Thanks, this works.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;BTW, how to auto-scale in y-axis for each?!&amp;nbsp; Though they are aligned up, I need auto-scale each y-axis.&amp;nbsp;&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="SGPanel1.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/109792iE48BFC9A5C31BAD8/image-size/large?v=v2&amp;amp;px=999" role="button" title="SGPanel1.png" alt="SGPanel1.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Sep 2025 08:22:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-SGPlot-n-by-m-with-varied-color/m-p/974577#M377935</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2025-09-09T08:22:23Z</dc:date>
    </item>
    <item>
      <title>Re: How to SGPlot n-by-m with varied color ?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-SGPlot-n-by-m-with-varied-color/m-p/974581#M377939</link>
      <description>Check the last example:&lt;BR /&gt;&lt;A href="https://blogs.sas.com/content/graphicallyspeaking/2022/09/10/complex-layouts-using-the-sg-procedures/" target="_blank"&gt;https://blogs.sas.com/content/graphicallyspeaking/2022/09/10/complex-layouts-using-the-sg-procedures/&lt;/A&gt;</description>
      <pubDate>Tue, 09 Sep 2025 09:02:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-SGPlot-n-by-m-with-varied-color/m-p/974581#M377939</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-09-09T09:02:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to SGPlot n-by-m with varied color ?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-SGPlot-n-by-m-with-varied-color/m-p/974597#M377947</link>
      <description>&lt;LI-SPOILER&gt;Thanks. It works on auto-scale. &lt;BR /&gt;&lt;BR /&gt;But how to let each plot has varied color?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data _test;
do grp=1 to 6;
	do ind=1 to 100;
		yvalue=sin(ind)+grp;
		output;
	end;
end;
run;quit;

ods printer printer=png300 file="bygroups.png" style=normalprinter;
ods layout gridded columns=3 rows=2 advance=bygroup
    column_gutter=0.1in row_gutter=0.1in;
ods graphics / width=2in;
title "_test by grp";
proc sgplot data=_test noautolegend uniform=xscale;
by grp;
series x=ind y=yvalue / group=grp lineattrs=( thickness=2 pattern=solid);     
	refline  30/axis=x;
run;
ods layout end;
ods printer close;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="bygroups.png" style="width: 999px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/109796i071D0EF36B2CAD90/image-size/large?v=v2&amp;amp;px=999" role="button" title="bygroups.png" alt="bygroups.png" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/LI-SPOILER&gt;</description>
      <pubDate>Tue, 09 Sep 2025 12:01:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-SGPlot-n-by-m-with-varied-color/m-p/974597#M377947</guid>
      <dc:creator>hellohere</dc:creator>
      <dc:date>2025-09-09T12:01:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to SGPlot n-by-m with varied color ?!</title>
      <link>https://communities.sas.com/t5/SAS-Programming/How-to-SGPlot-n-by-m-with-varied-color/m-p/974711#M377968</link>
      <description>&lt;P&gt;OK. That is need a some sophisticated skill "DATTRMAP= option" .&lt;/P&gt;
&lt;PRE&gt;options nodate nonumber;
options papersize=(7.35in 5.75in);
options leftmargin="0.001in" rightmargin="0.001in";
options nobyline;

data heart;
set sashelp.heart;
if (weight_status eq '') then weight_status="Unknown";
run;
proc sort data=heart; by weight_status; run;

title "Cholesterol Distribution by Weight Status";


&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;
data dattrmap;
infile cards truncover;
input id $ value :$20. linecolor $  ;
datalines;
x  Normal  red 
x  Overweight  blue 
x  Underweight  green 
;
run;&lt;/STRONG&gt;&lt;/FONT&gt;





ods printer printer=png300 file="bygroups.png" style=normalprinter;
ods layout gridded columns=2 rows=2 advance=bygroup
    column_gutter=0.1in row_gutter=0.1in;
ods graphics / width=3.5in ;
title "#byval1";
proc sgplot data=heart noautolegend uniform=xscale &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt; dattrmap=dattrmap&lt;/STRONG&gt;&lt;/FONT&gt; ;
&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;by weight_status;&lt;/STRONG&gt;&lt;/FONT&gt;
yaxis offsetmin=0.05;
series x=weight y=height /&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt; group=weight_status attrid=x&lt;/STRONG&gt;&lt;/FONT&gt;;
run;
ods layout end;
ods printer close;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1757486117037.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/109844i840D59AAE3D19BE2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1757486117037.png" alt="Ksharp_0-1757486117037.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Sep 2025 06:35:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/How-to-SGPlot-n-by-m-with-varied-color/m-p/974711#M377968</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-09-10T06:35:28Z</dc:date>
    </item>
  </channel>
</rss>

