<?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: Change name of group variable in a legend in SGPLOT in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Change-name-of-group-variable-in-a-legend-in-SGPLOT/m-p/722825#M224195</link>
    <description>&lt;P&gt;Sorry, that was a mistake. What version of SAS do you use?&lt;/P&gt;</description>
    <pubDate>Tue, 02 Mar 2021 09:28:42 GMT</pubDate>
    <dc:creator>PeterClemmensen</dc:creator>
    <dc:date>2021-03-02T09:28:42Z</dc:date>
    <item>
      <title>Change name of group variable in a legend in SGPLOT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-name-of-group-variable-in-a-legend-in-SGPLOT/m-p/722822#M224192</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I want to change the names in a SGPLOT legend. I am using a grouping variable in character format and I would like to change the names.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using SAS 9.4&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code looks like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA cars1;
 INPUT treatment $ ID score ;
CARDS;
base  1 2930 
advanced   1 3350 
base   2 2640 
advanced  2 6150 
base  3 4080 
advanced  3 5250
;
RUN; 

proc sgplot data=cars1;
hbox score / group=treatment;
keylegend;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;And my result is:&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="Screenshot 2021-03-02 at 10.17.33.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/55347i83F5B37364294E9C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screenshot 2021-03-02 at 10.17.33.png" alt="Screenshot 2021-03-02 at 10.17.33.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;How can I replace "base" and "advanced" with "base dose" and "advanced dose" ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance!&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 09:19:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-name-of-group-variable-in-a-legend-in-SGPLOT/m-p/722822#M224192</guid>
      <dc:creator>marta25</dc:creator>
      <dc:date>2021-03-02T09:19:26Z</dc:date>
    </item>
    <item>
      <title>Re: Change name of group variable in a legend in SGPLOT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-name-of-group-variable-in-a-legend-in-SGPLOT/m-p/722823#M224193</link>
      <description>&lt;P&gt;Simply change them in your data?&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 09:24:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-name-of-group-variable-in-a-legend-in-SGPLOT/m-p/722823#M224193</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-03-02T09:24:15Z</dc:date>
    </item>
    <item>
      <title>Re: Change name of group variable in a legend in SGPLOT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-name-of-group-variable-in-a-legend-in-SGPLOT/m-p/722824#M224194</link>
      <description>&lt;P&gt;No I can not change it in the dataset, I was looking for a quicker way.&amp;nbsp;&lt;/P&gt;&lt;P&gt;What do you mean by "create a label"?&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 09:24:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-name-of-group-variable-in-a-legend-in-SGPLOT/m-p/722824#M224194</guid>
      <dc:creator>marta25</dc:creator>
      <dc:date>2021-03-02T09:24:22Z</dc:date>
    </item>
    <item>
      <title>Re: Change name of group variable in a legend in SGPLOT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-name-of-group-variable-in-a-legend-in-SGPLOT/m-p/722825#M224195</link>
      <description>&lt;P&gt;Sorry, that was a mistake. What version of SAS do you use?&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 09:28:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-name-of-group-variable-in-a-legend-in-SGPLOT/m-p/722825#M224195</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2021-03-02T09:28:42Z</dc:date>
    </item>
    <item>
      <title>Re: Change name of group variable in a legend in SGPLOT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-name-of-group-variable-in-a-legend-in-SGPLOT/m-p/722827#M224196</link>
      <description>&lt;P&gt;I have SAS University Edition and it should be release 9.4.&lt;/P&gt;&lt;P&gt;I tried LEGENDITEM but it does not get highlighted, so I guess I do not have the version that supports it.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 09:35:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-name-of-group-variable-in-a-legend-in-SGPLOT/m-p/722827#M224196</guid>
      <dc:creator>marta25</dc:creator>
      <dc:date>2021-03-02T09:35:24Z</dc:date>
    </item>
    <item>
      <title>Re: Change name of group variable in a legend in SGPLOT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-name-of-group-variable-in-a-legend-in-SGPLOT/m-p/722836#M224201</link>
      <description>&lt;P&gt;I think that nearly 99% of the time when the question is "display this value instead of what is actually in the data" the response is a custom format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this:&lt;/P&gt;
&lt;PRE&gt;proc format;
value $dosegroup
'base'     = 'Base Dose'
'advanced' = 'Advanced Dose'
;
run;

proc sgplot data=cars1;
hbox score / group=treatment;
keylegend;
format treatment $dosegroup.;
run;&lt;/PRE&gt;</description>
      <pubDate>Tue, 02 Mar 2021 11:12:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-name-of-group-variable-in-a-legend-in-SGPLOT/m-p/722836#M224201</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-03-02T11:12:04Z</dc:date>
    </item>
    <item>
      <title>Re: Change name of group variable in a legend in SGPLOT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-name-of-group-variable-in-a-legend-in-SGPLOT/m-p/722841#M224204</link>
      <description>&lt;P&gt;Thanks, this works!&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, it generates another problem.&lt;/P&gt;&lt;P&gt;I was using an attribute map to set the colors in the box plot:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data myattrmap;
	length linecolor $ 9 fillcolor $ 9 value $ 12 ID $ 12;
	input ID $ value $ linecolor $ fillcolor $;
	datalines;
treatment  base black grey  
treatment  advanced green green 
;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Now if I try:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=data dattrmap=myattrmap;
hbox... / ...
attrid=treatment;&lt;BR /&gt;format treatment=$dosegroup;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The attribute map is not applied and I have the same plot as before with default colors.&lt;/P&gt;&lt;P&gt;Is there a way to keep using such attribute map?&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 11:48:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-name-of-group-variable-in-a-legend-in-SGPLOT/m-p/722841#M224204</guid>
      <dc:creator>marta25</dc:creator>
      <dc:date>2021-03-02T11:48:09Z</dc:date>
    </item>
    <item>
      <title>Re: Change name of group variable in a legend in SGPLOT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-name-of-group-variable-in-a-legend-in-SGPLOT/m-p/722876#M224220</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/329008"&gt;@marta25&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks, this works!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;However, it generates another problem.&lt;/P&gt;
&lt;P&gt;I was using an attribute map to set the colors in the box plot:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data myattrmap;
	length linecolor $ 9 fillcolor $ 9 value $ 12 ID $ 12;
	input ID $ value $ linecolor $ fillcolor $;
	datalines;
treatment  base black grey  
treatment  advanced green green 
;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Now if I try:&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=data dattrmap=myattrmap;
hbox... / ...
attrid=treatment;&lt;BR /&gt;format treatment=$dosegroup;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The attribute map is not applied and I have the same plot as before with default colors.&lt;/P&gt;
&lt;P&gt;Is there a way to keep using such attribute map?&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;The documentation for DATTRMAP sets pretty clearly states that the value has to be the Formatted value of a variable.&lt;/P&gt;
&lt;P&gt;So modify the value of the attribute data set.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 15:19:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-name-of-group-variable-in-a-legend-in-SGPLOT/m-p/722876#M224220</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-03-02T15:19:51Z</dc:date>
    </item>
    <item>
      <title>Re: Change name of group variable in a legend in SGPLOT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-name-of-group-variable-in-a-legend-in-SGPLOT/m-p/722905#M224236</link>
      <description>&lt;P&gt;Thanks for your reply. Do you mean I should change it in the dataset? Or how?&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 16:41:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-name-of-group-variable-in-a-legend-in-SGPLOT/m-p/722905#M224236</guid>
      <dc:creator>marta25</dc:creator>
      <dc:date>2021-03-02T16:41:35Z</dc:date>
    </item>
    <item>
      <title>Re: Change name of group variable in a legend in SGPLOT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-name-of-group-variable-in-a-legend-in-SGPLOT/m-p/722920#M224248</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/329008"&gt;@marta25&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Thanks for your reply. Do you mean I should change it in the dataset? Or how?&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Yes in the dattrmap set. Something like this is one way. The DSD option will allow a space in the value of a read variable when the value is enclosed in quotes. However, make sure there is only one space between values as consecutive blanks would mean a "missing" value. Or provide a different delimiter and the quotes wouldn't be needed. Note that value was made longer to fit Advanced dose.&lt;/P&gt;
&lt;PRE&gt;data myattrmap;
	length linecolor $ 9 fillcolor $ 9 value $ 15 ID $ 12;
   infile datalines dlm=' ' dsd;
	input ID $ value $ linecolor $ fillcolor $;
	datalines;
treatment "Base Dose" black grey  
treatment "Advanced Dose" green green 
;&lt;/PRE&gt;
&lt;P&gt;The value will be case sensitive.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Mar 2021 17:21:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-name-of-group-variable-in-a-legend-in-SGPLOT/m-p/722920#M224248</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2021-03-02T17:21:45Z</dc:date>
    </item>
    <item>
      <title>Re: Change name of group variable in a legend in SGPLOT</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Change-name-of-group-variable-in-a-legend-in-SGPLOT/m-p/722954#M224264</link>
      <description>Perfect, thank you so much!!</description>
      <pubDate>Tue, 02 Mar 2021 19:30:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Change-name-of-group-variable-in-a-legend-in-SGPLOT/m-p/722954#M224264</guid>
      <dc:creator>marta25</dc:creator>
      <dc:date>2021-03-02T19:30:26Z</dc:date>
    </item>
  </channel>
</rss>

