<?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: sgpanel - panel order in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/sgpanel-panel-order/m-p/344187#M11950</link>
    <description>&lt;P&gt;Based on your SGPANEL variable requests, the PROC SORT BY request should look like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=test; by grade year2; run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The YEAR1 variable should be dropped because it is not used in the graph. Also, remove the SORT=DATA from the PANELBY statement, as the order of the YEAR2 variable will already be maintained because the data has been properly presorted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps!&lt;/P&gt;
&lt;P&gt;Dan&lt;/P&gt;</description>
    <pubDate>Fri, 24 Mar 2017 19:33:18 GMT</pubDate>
    <dc:creator>DanH_sas</dc:creator>
    <dc:date>2017-03-24T19:33:18Z</dc:date>
    <item>
      <title>sgpanel - panel order</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/sgpanel-panel-order/m-p/344176#M11948</link>
      <description>&lt;P&gt;When I use only a single grade, the order is how I want/expect - ordered by the data, year1 (sgplot1#1)&lt;/P&gt;
&lt;P&gt;when I have two grades,&amp;nbsp;the panel order changes for the grade=2 panels (sgplot#2), &amp;nbsp;- any suggestions on how to keep the order?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;data test; &lt;BR /&gt;input grade year1 year2 $ pct1 pct2; &lt;BR /&gt;cards;&lt;BR /&gt;1 1 t3 .3 .5&lt;BR /&gt;1 2 t4 .2 .5&lt;BR /&gt;2 1 t1 .2 .5&lt;BR /&gt;2 2 t2 .4 .5&lt;BR /&gt;2 3 t3 .2 .6&lt;BR /&gt;2 4 t4 .4 .7&lt;BR /&gt;;&lt;BR /&gt;run;&lt;BR /&gt; &lt;BR /&gt;*#1;&lt;BR /&gt;data test1; set test; where grade = 2; run;&lt;BR /&gt; proc sort data= test1 ; by grade year1; run;&lt;BR /&gt;proc sgpanel data=test1; &lt;BR /&gt;panelby year2 / rows=2 columns=2 sort=data; &lt;BR /&gt;Scatter y = pct1 x = pct2 /; by grade;&lt;BR /&gt; run;&lt;/P&gt;
&lt;P&gt;*#2; &lt;BR /&gt; proc sort data=test ; by grade year1; run;&lt;BR /&gt;proc sgpanel data=test CYCLEATTRS; &lt;BR /&gt;panelby year2 / rows=2 columns=2 sort=data; &lt;BR /&gt;Scatter y = pct1 x = pct2; by grade;&lt;BR /&gt; run;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2017 19:04:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/sgpanel-panel-order/m-p/344176#M11948</guid>
      <dc:creator>Dave25</dc:creator>
      <dc:date>2017-03-24T19:04:23Z</dc:date>
    </item>
    <item>
      <title>Re: sgpanel - panel order</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/sgpanel-panel-order/m-p/344183#M11949</link>
      <description>&lt;P&gt;I am not quite sure why you sort by year1 but the use panel by year2.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the specific data shown the order works for the grade 2 data because the Year1 and Year2 sort order would be the same.&lt;/P&gt;
&lt;P&gt;Since for grade 1 you have year2 valures of t3 and t1 for year1 values of 1&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe you you need to sort by grade year2?&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2017 19:25:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/sgpanel-panel-order/m-p/344183#M11949</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-03-24T19:25:38Z</dc:date>
    </item>
    <item>
      <title>Re: sgpanel - panel order</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/sgpanel-panel-order/m-p/344187#M11950</link>
      <description>&lt;P&gt;Based on your SGPANEL variable requests, the PROC SORT BY request should look like this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;proc sort data=test; by grade year2; run;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The YEAR1 variable should be dropped because it is not used in the graph. Also, remove the SORT=DATA from the PANELBY statement, as the order of the YEAR2 variable will already be maintained because the data has been properly presorted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps!&lt;/P&gt;
&lt;P&gt;Dan&lt;/P&gt;</description>
      <pubDate>Fri, 24 Mar 2017 19:33:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/sgpanel-panel-order/m-p/344187#M11950</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2017-03-24T19:33:18Z</dc:date>
    </item>
    <item>
      <title>Re: sgpanel - panel order</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/sgpanel-panel-order/m-p/344301#M11962</link>
      <description>&lt;P&gt;thank you for the suggestions - it looks like I did a poor job expaining my problem. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My issue is that I need &amp;nbsp;panelby ordered by year2 while sorting on year1 (I've got a number&amp;nbsp; grades, year1's and year2's, and year1 is not always equal to year2, for different grades) &amp;nbsp;- I thought using data=sort in the panelby statement would provide the order of panels, but it doesn't (it appears to want to replicate the order from the 1st bygroup)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I submitted the question to SAS Tech support, and it appears to be an internal problem. &amp;nbsp;Their response:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;--------------------------------------------------------&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Since you're using a BY statement, the SGPANEL procedure appears to be performing an internal sort of the data that causes the panels to be in a different order.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;I'll send this to development to fix for the future.&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;In the meantime, you can use a macro to run the SGPANEL procedure using a WHERE statement for each value of the BY variable rather than using a BY statement. &amp;nbsp;For example:&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;proc&lt;/SPAN&gt; &lt;SPAN&gt;sort&lt;/SPAN&gt; &lt;SPAN&gt;data&lt;/SPAN&gt;&lt;SPAN&gt;=test_sas ; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;by&lt;/SPAN&gt;&lt;SPAN&gt; grade y &amp;nbsp;pct1 pct2; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;run&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%macro&lt;/SPAN&gt;&lt;SPAN&gt; panel(byval);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;title &lt;/SPAN&gt;&lt;SPAN&gt;"Grade=&amp;amp;byval"&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;proc sgpanel data=test_sas ; &amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; where grade=&amp;amp;byval;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; panelby year / rows=&lt;/SPAN&gt;&lt;SPAN&gt;2&lt;/SPAN&gt;&lt;SPAN&gt; columns=&lt;/SPAN&gt;&lt;SPAN&gt;2&lt;/SPAN&gt;&lt;SPAN&gt; NOVARNAME sort=data &amp;nbsp;; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; Scatter y = pct1&amp;nbsp;x = &amp;nbsp;pct2; &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;run;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;%mend&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;data&lt;/SPAN&gt; &lt;SPAN&gt;_null_&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;set&lt;/SPAN&gt;&lt;SPAN&gt; test_sas;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;by&lt;/SPAN&gt;&lt;SPAN&gt; grade;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt; first.grade &lt;/SPAN&gt;&lt;SPAN&gt;then&lt;/SPAN&gt; &lt;SPAN&gt;call&lt;/SPAN&gt;&lt;SPAN&gt; execute(&lt;/SPAN&gt;&lt;SPAN&gt;'%PANEL('&lt;/SPAN&gt;&lt;SPAN&gt; || trim(grade) ||&lt;/SPAN&gt;&lt;SPAN&gt;')'&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;run&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;nbsp;As an alternative to using the WHERE statement in PROC SGPANEL, you can create the graph using the Graph Template Language (GTL) with the DATAPANEL layout. For example:&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&amp;nbsp;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;ods&lt;/SPAN&gt; &lt;SPAN&gt;path&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;prepend&lt;/SPAN&gt;&lt;SPAN&gt;) work.template(&lt;/SPAN&gt;&lt;SPAN&gt;update&lt;/SPAN&gt;&lt;SPAN&gt;);&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;proc&lt;/SPAN&gt; &lt;SPAN&gt;template&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;define&lt;/SPAN&gt; &lt;SPAN&gt;statgraph&lt;/SPAN&gt;&lt;SPAN&gt; panels;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&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;P&gt;&lt;SPAN&gt;run&lt;/SPAN&gt;&lt;SPAN&gt;;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 25 Mar 2017 15:12:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/sgpanel-panel-order/m-p/344301#M11962</guid>
      <dc:creator>Dave25</dc:creator>
      <dc:date>2017-03-25T15:12:23Z</dc:date>
    </item>
    <item>
      <title>Re: sgpanel - panel order</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/sgpanel-panel-order/m-p/344795#M11996</link>
      <description>&lt;P&gt;Since &lt;STRONG&gt;none&lt;/STRONG&gt; of your exampl sgpanel code uses or mentions the &lt;STRONG&gt;year1&lt;/STRONG&gt; variable at all then why does it require sorting by year1?&lt;/P&gt;
&lt;P&gt;Yes it may be needed for a different step but not for the sgpanel code as shown. So resort afterwards to do the other steps, or possibly use two different data sets.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But is suspect that you meant originally but did not say so that you needed completely separate output for each level of year1.&lt;/P&gt;
&lt;P&gt;Which is why we often say: SHOW what you want for the output and provide enough data that it the result is possible from the given data and the data is not trivial&lt;/P&gt;</description>
      <pubDate>Mon, 27 Mar 2017 21:02:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/sgpanel-panel-order/m-p/344795#M11996</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-03-27T21:02:16Z</dc:date>
    </item>
  </channel>
</rss>

