<?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: Sortoder keylegend sgplot in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Sortoder-keylegend-sgplot/m-p/416448#M14284</link>
    <description>&lt;P&gt;Great solution, Anita!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A related tip:&lt;/P&gt;
&lt;P&gt;When using the SHOW and NOCASE columns, I usually RETAIN the values for the attrmap, as you can have only one value for these columns per map. Using RETAIN helps simplify the data step a bit:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data attrmap;&lt;/P&gt;
&lt;P&gt;retain show "attrmap";&lt;/P&gt;
&lt;P&gt;input id $ value $10.&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/131792" target="_blank"&gt;@19&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;fillcolor $8.;&lt;BR /&gt;datalines;&lt;/P&gt;
&lt;P&gt;flavor&lt;U&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Vanilla&lt;/U&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;beige &amp;nbsp; &amp;nbsp;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;flavor&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;U&gt;Chocolate&lt;/U&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;cx663D29&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;BR /&gt;flavor&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;U&gt;Strawberry&lt;/U&gt;&lt;STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;pink&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
    <pubDate>Mon, 27 Nov 2017 16:03:35 GMT</pubDate>
    <dc:creator>DanH_sas</dc:creator>
    <dc:date>2017-11-27T16:03:35Z</dc:date>
    <item>
      <title>Sortoder keylegend sgplot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Sortoder-keylegend-sgplot/m-p/414790#M14236</link>
      <description>&lt;P&gt;I have a question. I need to sort the labels displayed in my legend in a particular order. Not descending, ascending nor reversed.&lt;/P&gt;&lt;P&gt;Is there any way to do that?&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 09:56:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Sortoder-keylegend-sgplot/m-p/414790#M14236</guid>
      <dc:creator>Anita_n</dc:creator>
      <dc:date>2017-11-20T09:56:01Z</dc:date>
    </item>
    <item>
      <title>Re: Sortoder keylegend sgplot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Sortoder-keylegend-sgplot/m-p/414793#M14237</link>
      <description>&lt;P&gt;What plot are you talking about? Show us some of your code &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or perhaps this article can help you:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://blogs.sas.com/content/graphicallyspeaking/2014/08/03/legend-order-in-sgplot-procedure/" target="_self"&gt;Legend Order in SGPLOT Procedure&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 10:06:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Sortoder-keylegend-sgplot/m-p/414793#M14237</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-11-20T10:06:23Z</dc:date>
    </item>
    <item>
      <title>Re: Sortoder keylegend sgplot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Sortoder-keylegend-sgplot/m-p/414796#M14238</link>
      <description>&lt;P&gt;The simplest way is to set your labels to be numbers in the order you want to see them, and then apply a format to the labels so they show the text, e.g.:&lt;/P&gt;
&lt;PRE&gt;proc format;
  value temp
    1="Value 2"
     2="Value 3"
     3="Value 1";
run;

data have;
  set have;
  if lab="Value 2" then labn=1;
  ...;
  format labn temp.;
run;
&lt;/PRE&gt;
&lt;P&gt;Then use labn as your labels, this will sort by the number, and display the test per the format.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 10:21:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Sortoder-keylegend-sgplot/m-p/414796#M14238</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-11-20T10:21:22Z</dc:date>
    </item>
    <item>
      <title>Re: Sortoder keylegend sgplot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Sortoder-keylegend-sgplot/m-p/414847#M14241</link>
      <description>&lt;P&gt;Thanks RW9 for your reply am still trying to implement that in sgplot but it hasn't worked yet. I hope it works.&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 14:25:58 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Sortoder-keylegend-sgplot/m-p/414847#M14241</guid>
      <dc:creator>Anita_n</dc:creator>
      <dc:date>2017-11-20T14:25:58Z</dc:date>
    </item>
    <item>
      <title>Re: Sortoder keylegend sgplot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Sortoder-keylegend-sgplot/m-p/414848#M14242</link>
      <description>&lt;P&gt;No probs.&amp;nbsp; You might want to favourite this site:&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.sas.com/content/graphicallyspeaking/" target="_blank"&gt;http://blogs.sas.com/content/graphicallyspeaking/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Its has thousands of examples of all types of graphs using sgplot/gtl.&amp;nbsp; Very useful.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 14:27:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Sortoder-keylegend-sgplot/m-p/414848#M14242</guid>
      <dc:creator>RW9</dc:creator>
      <dc:date>2017-11-20T14:27:10Z</dc:date>
    </item>
    <item>
      <title>Re: Sortoder keylegend sgplot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Sortoder-keylegend-sgplot/m-p/414849#M14243</link>
      <description>&lt;P&gt;Thanks draycut for your reply am still trying to implement that but it hasn't worked yet. I hope am not making any mistake. I will let you know if it worked&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 14:27:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Sortoder-keylegend-sgplot/m-p/414849#M14243</guid>
      <dc:creator>Anita_n</dc:creator>
      <dc:date>2017-11-20T14:27:18Z</dc:date>
    </item>
    <item>
      <title>Re: Sortoder keylegend sgplot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Sortoder-keylegend-sgplot/m-p/414850#M14244</link>
      <description>&lt;P&gt;Anytime.. Post your code if you want a more usable answer &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Nov 2017 14:33:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Sortoder-keylegend-sgplot/m-p/414850#M14244</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-11-20T14:33:24Z</dc:date>
    </item>
    <item>
      <title>Re: Sortoder keylegend sgplot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Sortoder-keylegend-sgplot/m-p/415052#M14253</link>
      <description>&lt;DIV class="lia-message-heading lia-component-message-header"&gt;&lt;DIV class="lia-quilt-row lia-quilt-row-standard"&gt;&lt;DIV class="lia-quilt-column lia-quilt-column-20 lia-quilt-column-left"&gt;&lt;DIV class="lia-quilt-column-alley lia-quilt-column-alley-left"&gt;&lt;DIV class="lia-message-subject"&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;DIV class="MessageReadByModeratorCell lia-moderation-moderated"&gt;Hello draycut, hello RW9,&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class="lia-message-body lia-component-body"&gt;&lt;DIV class="lia-message-body-content"&gt;&lt;P&gt;thanks for the help, It unfortunately didn't work with your suggestions, I probably might have made a mistake some where in the code but I finally found a very easy way to solve the problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the issue is that I wanted to sort the listed items in my keylegend. Not using ascending or descending order as used in Sortorder (the Keylegend Statement).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I solved the problem this way: since I have set the order already in my attrmap while assigning colors to the bars. I just added an extra column to my attrmap which is Show = "Attrmap"&lt;/P&gt;&lt;P&gt;this displays the legend items in the order which is defined in the Attrmap for a example if you assign colors this way using attrmap&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data attrmap;&lt;/P&gt;&lt;P&gt;input id $ value $10. &lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/131792" target="_blank"&gt;@19&lt;/A&gt; fillcolor $8. show $10.;&lt;BR /&gt;datalines;&lt;/P&gt;&lt;P&gt;flavor&lt;U&gt; Vanilla&lt;/U&gt; &lt;STRONG&gt;beige &amp;nbsp; &amp;nbsp;&lt;/STRONG&gt; attrmap&lt;BR /&gt;flavor &lt;U&gt;Chocolate&lt;/U&gt; &lt;STRONG&gt;cx663D29&amp;nbsp; &lt;/STRONG&gt;attrmap&lt;BR /&gt;flavor &lt;U&gt;Strawberry&lt;/U&gt;&lt;STRONG&gt; pink &lt;/STRONG&gt;attrmap&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this will display the items in your legend in this order vanilla, Chocolate, Strawberry&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 21 Nov 2017 07:37:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Sortoder-keylegend-sgplot/m-p/415052#M14253</guid>
      <dc:creator>Anita_n</dc:creator>
      <dc:date>2017-11-21T07:37:42Z</dc:date>
    </item>
    <item>
      <title>Re: Sortoder keylegend sgplot</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Sortoder-keylegend-sgplot/m-p/416448#M14284</link>
      <description>&lt;P&gt;Great solution, Anita!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A related tip:&lt;/P&gt;
&lt;P&gt;When using the SHOW and NOCASE columns, I usually RETAIN the values for the attrmap, as you can have only one value for these columns per map. Using RETAIN helps simplify the data step a bit:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;data attrmap;&lt;/P&gt;
&lt;P&gt;retain show "attrmap";&lt;/P&gt;
&lt;P&gt;input id $ value $10.&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/131792" target="_blank"&gt;@19&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;fillcolor $8.;&lt;BR /&gt;datalines;&lt;/P&gt;
&lt;P&gt;flavor&lt;U&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Vanilla&lt;/U&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;beige &amp;nbsp; &amp;nbsp;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;BR /&gt;flavor&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;U&gt;Chocolate&lt;/U&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;cx663D29&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;BR /&gt;flavor&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;U&gt;Strawberry&lt;/U&gt;&lt;STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;pink&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 27 Nov 2017 16:03:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Sortoder-keylegend-sgplot/m-p/416448#M14284</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2017-11-27T16:03:35Z</dc:date>
    </item>
  </channel>
</rss>

