<?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 is it possible to add legendlabels to grouped variables using prog sgplot? in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/How-is-it-possible-to-add-legendlabels-to-grouped-variables/m-p/284241#M59316</link>
    <description>&lt;P&gt;You need make two legend .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
call streaminit(1234);
 do i=1 to 100;
  var1=ceil(10*rand('uniform'));
  var2=ceil(10*rand('uniform'));
  output;
 end;
drop i;
run;
proc summary data=data1 nway;
 class var1;
 var var2;
 output out=per(drop=_:) p10= p50= p90= /autoname;
run;
proc transpose data=per out=temp;
by var1;
var var2_:;
run;
data data1;
 set have temp temp(in=in);
 if in then do;col2=col1-2;col1=.;end;
run;

proc sgplot data=data1;
scatter x=Var1 y=Var2;
series x=Var1 y=col1 / group=_name_  name="G";
series x=Var1 y=col2 / group=_name_  name="OG";
keylegend "G"/title='Gew'  position=top ;
keylegend "OG"/title='OhneGew'  position=top ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/4048iFF2984C81EC7AFE7/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="x.png" title="x.png" /&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 14 Jul 2016 04:22:19 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2016-07-14T04:22:19Z</dc:date>
    <item>
      <title>How is it possible to add legendlabels to grouped variables using prog sgplot?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-is-it-possible-to-add-legendlabels-to-grouped-variables/m-p/283984#M59280</link>
      <description>&lt;P&gt;I am trying to add legendlabels to grouped variables using proc sgplot in SAS 9.4. Therefore I considered the keylegend statement as mentioned below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods graphics on / labelmax=42100 antialiasmax=42100;
proc sgplot data=data1;
title "QuantReg";
xaxis label="Var1" type=discrete;
yaxis label="Var2";
scatter x=Var1 y=Var2 / markerattrs=(size=3 color=grey);
series x=Var1 y=Var3 / group=quantile legendlabel="Gew" name="G";
series x=Var1 y=Var4 / group=quantile lineattrs=(pattern=dot) legendlabel="OhneGew" name="OG";
keylegend "G" "OG" / location=inside position=topleft title="Quantile" titleattrs=(weight=bold) across=3;
run;
title;
ods graphics off;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But I only get the legend without a description of the quantiles. Is there another way in order to add labels to the grouped variables?&lt;BR /&gt;&lt;BR /&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jul 2016 08:50:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-is-it-possible-to-add-legendlabels-to-grouped-variables/m-p/283984#M59280</guid>
      <dc:creator>DaLack</dc:creator>
      <dc:date>2016-07-13T08:50:00Z</dc:date>
    </item>
    <item>
      <title>Re: How is it possible to add legendlabels to grouped variables using prog sgplot?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-is-it-possible-to-add-legendlabels-to-grouped-variables/m-p/283993#M59282</link>
      <description>&lt;P&gt;I don't understand your question. Can you post some data and the picture to show what you want.&lt;/P&gt;
&lt;P&gt;Better post it at Forum:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A class="" href="https://communities.sas.com/t5/SAS-GRAPH-and-ODS-Graphics/bd-p/sas_graph" target="_blank"&gt;SAS/GRAPH and ODS Graphics&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Jul 2016 09:24:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-is-it-possible-to-add-legendlabels-to-grouped-variables/m-p/283993#M59282</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-07-13T09:24:00Z</dc:date>
    </item>
    <item>
      <title>Re: How is it possible to add legendlabels to grouped variables using prog sgplot?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-is-it-possible-to-add-legendlabels-to-grouped-variables/m-p/284020#M59284</link>
      <description>&lt;P&gt;Thanks for your efforts.&lt;BR /&gt;&lt;BR /&gt;My sgplot looks like the attached one. The corresponding code for this example is:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods graphics on / labelmax=42100 antialiasmax=42100;
proc sgplot data=data1;
scatter x=Var1 y=Var2;
series x=Var1 y=Var3 / group=quantile legendlabel="Gew" name="G";
series x=Var1 y=Var4 / group=quantile legendlabel="OhneGew" name="OG";
keylegend "G" "OG" / location=inside position=topleft title="Quantile" titleattrs=(weight=bold) across=3;
run;
ods graphics off;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I want to plot the results of two quantile regressions. I a got grouped variable called "quantile" with the 5th, 50th and 95th percentiles. My aim is to label the two outcomes with "Gew" for the three percentiles of the first regression and with "OhneGew" for the three percentiles of the second regression. Therefore I used the keylegend statement along with the legendlabel statement. But as a result, I only get a legend without the description "Gew" and "OhneGew". With respect to the attached sgplot, I want to modify the given legend. The first row of the legend should begin with "Gew" and the second one with "OhneGew".&lt;BR /&gt;&lt;BR /&gt;Many thanks for your help!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/12748i22E307D63E519991/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="SGPlot.png" title="SGPlot.png" /&gt;</description>
      <pubDate>Wed, 13 Jul 2016 13:15:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-is-it-possible-to-add-legendlabels-to-grouped-variables/m-p/284020#M59284</guid>
      <dc:creator>DaLack</dc:creator>
      <dc:date>2016-07-13T13:15:09Z</dc:date>
    </item>
    <item>
      <title>Re: How is it possible to add legendlabels to grouped variables using prog sgplot?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-is-it-possible-to-add-legendlabels-to-grouped-variables/m-p/284241#M59316</link>
      <description>&lt;P&gt;You need make two legend .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data have;
call streaminit(1234);
 do i=1 to 100;
  var1=ceil(10*rand('uniform'));
  var2=ceil(10*rand('uniform'));
  output;
 end;
drop i;
run;
proc summary data=data1 nway;
 class var1;
 var var2;
 output out=per(drop=_:) p10= p50= p90= /autoname;
run;
proc transpose data=per out=temp;
by var1;
var var2_:;
run;
data data1;
 set have temp temp(in=in);
 if in then do;col2=col1-2;col1=.;end;
run;

proc sgplot data=data1;
scatter x=Var1 y=Var2;
series x=Var1 y=col1 / group=_name_  name="G";
series x=Var1 y=col2 / group=_name_  name="OG";
keylegend "G"/title='Gew'  position=top ;
keylegend "OG"/title='OhneGew'  position=top ;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/4048iFF2984C81EC7AFE7/image-size/original?v=v2&amp;amp;px=-1" border="0" alt="x.png" title="x.png" /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jul 2016 04:22:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-is-it-possible-to-add-legendlabels-to-grouped-variables/m-p/284241#M59316</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2016-07-14T04:22:19Z</dc:date>
    </item>
    <item>
      <title>Re: How is it possible to add legendlabels to grouped variables using prog sgplot?</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/How-is-it-possible-to-add-legendlabels-to-grouped-variables/m-p/284273#M59320</link>
      <description>&lt;P&gt;Thanks for your help. I thought about one legend but this solution is a good compromise.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Jul 2016 09:00:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/How-is-it-possible-to-add-legendlabels-to-grouped-variables/m-p/284273#M59320</guid>
      <dc:creator>DaLack</dc:creator>
      <dc:date>2016-07-14T09:00:24Z</dc:date>
    </item>
  </channel>
</rss>

