<?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: SGPLOT Customize legend in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/SGPLOT-Customize-legend/m-p/978450#M25713</link>
    <description>&lt;P&gt;You want this ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc summary data=sashelp.stocks nway;
class stock date;
format date year4.;
var close;
output out=have lclm=lclm uclm=uclm mean=mean;
run;




%let path=%sysfunc(pathname(work));  *the path stored the picture for Legend ;
*Make a picture for Legend;
data x;
infile cards truncover;
input stock :$20. x y center lower upper label_pos;
cards;
IBM 1.5 3 
IBM 2 3 2  2.6  3.4  2.5
IBM 2.5 3 
Intel 1.5 2 
Intel 2 2 2  1.6  2.4  2.5
Intel 2.5 2 
Microsoft 1.5 1 
Microsoft 2 1 2  0.6  1.4  2.5
Microsoft 2.5 1 
;
run;
title;
ods listing gpath="&amp;amp;path." style=htmlblue image_dpi=300;
ods graphics/width=140px height=100px reset=index imagename='legend' outputfmt=png noborder attrpriority=none;
proc sgplot data=x noautolegend pad=0 noborder;
styleattrs datacontrastcolors=(black blue red lime) datacolors=(black blue red lime) 
           datasymbols=(Asterisk Circle TriangleDown Triangle);

series x=x y=y/lineattrs=(pattern=solid) group=stock;
scatter x=center y=y/markerattrs=(size=15)  yerrorlower=lower yerrorupper=upper group=stock;
scatter x=label_pos y=y/datalabel=stock datalabelattrs=(size=15) labelstrip
                        markerattrs=(size=0) datalabelpos=right group=stock;

xaxis display=none   offsetmax=0.5; 
yaxis display=none  ; *offsetmin=0.1 offsetmax=0.1;
run;






%sganno
data sganno;
 %SGIMAGE(
     IMAGE="&amp;amp;path.\legend1.png",
     ANCHOR="CENTER" ,
	 IMAGESCALE="FITHEIGHT",
	 HEIGHT=25,
     HEIGHTUNIT= "PERCENT",
     LAYER="FRONT",

     DRAWSPACE="WALLPERCENT",
     X1=88,
     Y1=88,ID="BAR"
     )
run;
ods graphics /reset=all attrpriority=none;
proc sgplot data=have  sganno=sganno  noborder noautolegend;
styleattrs datacontrastcolors=(black blue red lime) datasymbols=(Asterisk Circle TriangleDown Triangle);
series x=date y=mean /group=stock markers lineattrs=(pattern=solid);
scatter x=date y=mean / group=stock yerrorlower=lclm
yerrorupper=uclm
markerattrs=(size=8)
errorbarattrs=(thickness=1);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1762418678863.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/111203i9D0F5567F0452AE5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1762418678863.png" alt="Ksharp_0-1762418678863.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 06 Nov 2025 09:41:30 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2025-11-06T09:41:30Z</dc:date>
    <item>
      <title>SGPLOT Customize legend</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/SGPLOT-Customize-legend/m-p/978410#M25711</link>
      <description>&lt;P&gt;Hi All, I’m trying to display the error bars in the legend of my SGPLOT output. I’m using the following code to generate the graph, but I haven’t been able to figure out why the error bars are not appearing in the legend.&lt;BR /&gt;Could someone please help me identify what’s going wrong with the code?&lt;/P&gt;&lt;P&gt;proc sgplot data=have dattrmap=test noautolegend noborder;&lt;/P&gt;&lt;P&gt;styleattrs datacontrastcolors=(black blue red lime) datasymbols=(Asterisk Circle TriangleDown Triangle);&lt;BR /&gt;series x=xvar y=mn / name="scatter1" group=trt attrid=X markers;&lt;BR /&gt;scatter x=xvar y=mn / name="scatter2" group=trtan yerrorlower=lower&lt;BR /&gt;yerrorupper=upper&lt;BR /&gt;markerattrs=(size=8)&lt;BR /&gt;errorbarattrs=(thickness=1);&lt;/P&gt;&lt;P&gt;legenditem type=markerline name="A" /&lt;BR /&gt;label="A (N=%trim(&amp;amp;A))" lineattrs=GraphData1 markerattrs=GraphData1;&lt;BR /&gt;legenditem type=markerline name="B" /&lt;BR /&gt;label="B (N=%trim(&amp;amp;B))" lineattrs=GraphData2 markerattrs=GraphData2;&lt;BR /&gt;legenditem type=markerline name="C" /&lt;BR /&gt;label="C (N=%trim(&amp;amp;C))" lineattrs=GraphData3 markerattrs=GraphData3;&lt;BR /&gt;legenditem type=markerline name="D" /&lt;BR /&gt;label="D (N=%trim(&amp;amp;D))" lineattrs=GraphData4 markerattrs=GraphData4;&lt;BR /&gt;&lt;BR /&gt;keylegend "A" "B" "C" "D"/ location=inside noborder opaque position=TOPRIGHT across=1 down=4;&lt;BR /&gt;yaxis label="Plasma (ug/L)" values = (0 200 400 600 800 1000) TICKSTYLE=INSIDE offsetmin=0.05&lt;BR /&gt;valueattrs=(family="Times New Roman" size=9) labelattrs=(family="Times New Roman" size=9);&lt;BR /&gt;xaxis label="Time (h)" values = (0 6 12 18 24 30 36 42 48) TICKSTYLE=INSIDE offsetmin=0.05&lt;BR /&gt;fitpolicy=rotate valueattrs=(family="Times New Roman" size=9) labelattrs=(family="Times New Roman" size=9);*valuesformat=vissc_.;*;&lt;BR /&gt;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 05 Nov 2025 15:41:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/SGPLOT-Customize-legend/m-p/978410#M25711</guid>
      <dc:creator>csa</dc:creator>
      <dc:date>2025-11-05T15:41:34Z</dc:date>
    </item>
    <item>
      <title>Re: SGPLOT Customize legend</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/SGPLOT-Customize-legend/m-p/978437#M25712</link>
      <description>Can you post a graph to explain what error bar you need to display in keylegend ?&lt;BR /&gt;And as far as I know you cann't display error bar in keylegend, and you need another workaround way to get job done.</description>
      <pubDate>Thu, 06 Nov 2025 07:06:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/SGPLOT-Customize-legend/m-p/978437#M25712</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-11-06T07:06:14Z</dc:date>
    </item>
    <item>
      <title>Re: SGPLOT Customize legend</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/SGPLOT-Customize-legend/m-p/978450#M25713</link>
      <description>&lt;P&gt;You want this ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;
proc summary data=sashelp.stocks nway;
class stock date;
format date year4.;
var close;
output out=have lclm=lclm uclm=uclm mean=mean;
run;




%let path=%sysfunc(pathname(work));  *the path stored the picture for Legend ;
*Make a picture for Legend;
data x;
infile cards truncover;
input stock :$20. x y center lower upper label_pos;
cards;
IBM 1.5 3 
IBM 2 3 2  2.6  3.4  2.5
IBM 2.5 3 
Intel 1.5 2 
Intel 2 2 2  1.6  2.4  2.5
Intel 2.5 2 
Microsoft 1.5 1 
Microsoft 2 1 2  0.6  1.4  2.5
Microsoft 2.5 1 
;
run;
title;
ods listing gpath="&amp;amp;path." style=htmlblue image_dpi=300;
ods graphics/width=140px height=100px reset=index imagename='legend' outputfmt=png noborder attrpriority=none;
proc sgplot data=x noautolegend pad=0 noborder;
styleattrs datacontrastcolors=(black blue red lime) datacolors=(black blue red lime) 
           datasymbols=(Asterisk Circle TriangleDown Triangle);

series x=x y=y/lineattrs=(pattern=solid) group=stock;
scatter x=center y=y/markerattrs=(size=15)  yerrorlower=lower yerrorupper=upper group=stock;
scatter x=label_pos y=y/datalabel=stock datalabelattrs=(size=15) labelstrip
                        markerattrs=(size=0) datalabelpos=right group=stock;

xaxis display=none   offsetmax=0.5; 
yaxis display=none  ; *offsetmin=0.1 offsetmax=0.1;
run;






%sganno
data sganno;
 %SGIMAGE(
     IMAGE="&amp;amp;path.\legend1.png",
     ANCHOR="CENTER" ,
	 IMAGESCALE="FITHEIGHT",
	 HEIGHT=25,
     HEIGHTUNIT= "PERCENT",
     LAYER="FRONT",

     DRAWSPACE="WALLPERCENT",
     X1=88,
     Y1=88,ID="BAR"
     )
run;
ods graphics /reset=all attrpriority=none;
proc sgplot data=have  sganno=sganno  noborder noautolegend;
styleattrs datacontrastcolors=(black blue red lime) datasymbols=(Asterisk Circle TriangleDown Triangle);
series x=date y=mean /group=stock markers lineattrs=(pattern=solid);
scatter x=date y=mean / group=stock yerrorlower=lclm
yerrorupper=uclm
markerattrs=(size=8)
errorbarattrs=(thickness=1);
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1762418678863.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/111203i9D0F5567F0452AE5/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1762418678863.png" alt="Ksharp_0-1762418678863.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 Nov 2025 09:41:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/SGPLOT-Customize-legend/m-p/978450#M25713</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-11-06T09:41:30Z</dc:date>
    </item>
  </channel>
</rss>

