<?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 Error with Proc SGPLOT, Vbar, Response, and categoryorder=respdesc; in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/Error-with-Proc-SGPLOT-Vbar-Response-and-categoryorder-respdesc/m-p/309145#M10851</link>
    <description>&lt;P&gt;I am having a problem using the categoryorder option in a sgplot procedure with a vbar statement and a response variable. My variable CNT is a three-character discrete variable, my PV1Math variable is a numeric variable. What I want to do is to replicate what I can easily do in SAS/Graph with SGPLot.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have some students who have Windows 9.4 TS1M3 and have SAS/Graph and other students who are using SAS UE and thus do not have access to SAS/Graph. I want to have them do homework assignments and produce similiar results.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For SAS/Graph, I get what I want with:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc gchart data=one;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;vbar cnt / sumvar=pv1math type=mean descending;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;quit;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But what I believe should give me the equivalent result using SGPLOT is giving me an error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc sgplot data=one;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; vbar cnt / response=pvt1math stat=mean categoryorder=respdesc;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get: &lt;STRONG&gt;WARNING: The data for a BARCHARTPARM statement are not appropriate. The BARCHARTPARM statement expects summarized data. The bar chart might not be drawn correctly.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In fact, I do get a bar chart that is not drawn correctly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am surprised as the SAS 9.4 ODS Graphics Procedure Guide, Fifth Edition, on page 1014 says I am supposed to have a response variable to use the categoryorder option. Additionally, as I am using VBAR I don't need to use summarized data. VBARPARM does require summarized data, so it appears as if the procedure is confusing VBAR and VBARPARM.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know I can fix the problem with an xaxis statement and value option to force the bars to be descending in values. I am trying not to have to teach too different things to SAS UE students and SAS/Graph students.(I don't want to have them use xaxis or learn Graph Template Language.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't see my issue as a known bug. I wanted to make sure I was interpretting things correctly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 03 Nov 2016 20:38:49 GMT</pubDate>
    <dc:creator>sugiyama</dc:creator>
    <dc:date>2016-11-03T20:38:49Z</dc:date>
    <item>
      <title>Error with Proc SGPLOT, Vbar, Response, and categoryorder=respdesc;</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Error-with-Proc-SGPLOT-Vbar-Response-and-categoryorder-respdesc/m-p/309145#M10851</link>
      <description>&lt;P&gt;I am having a problem using the categoryorder option in a sgplot procedure with a vbar statement and a response variable. My variable CNT is a three-character discrete variable, my PV1Math variable is a numeric variable. What I want to do is to replicate what I can easily do in SAS/Graph with SGPLot.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have some students who have Windows 9.4 TS1M3 and have SAS/Graph and other students who are using SAS UE and thus do not have access to SAS/Graph. I want to have them do homework assignments and produce similiar results.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;For SAS/Graph, I get what I want with:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc gchart data=one;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;vbar cnt / sumvar=pv1math type=mean descending;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;quit;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But what I believe should give me the equivalent result using SGPLOT is giving me an error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;proc sgplot data=one;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; vbar cnt / response=pvt1math stat=mean categoryorder=respdesc;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;run;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get: &lt;STRONG&gt;WARNING: The data for a BARCHARTPARM statement are not appropriate. The BARCHARTPARM statement expects summarized data. The bar chart might not be drawn correctly.&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In fact, I do get a bar chart that is not drawn correctly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am surprised as the SAS 9.4 ODS Graphics Procedure Guide, Fifth Edition, on page 1014 says I am supposed to have a response variable to use the categoryorder option. Additionally, as I am using VBAR I don't need to use summarized data. VBARPARM does require summarized data, so it appears as if the procedure is confusing VBAR and VBARPARM.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I know I can fix the problem with an xaxis statement and value option to force the bars to be descending in values. I am trying not to have to teach too different things to SAS UE students and SAS/Graph students.(I don't want to have them use xaxis or learn Graph Template Language.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't see my issue as a known bug. I wanted to make sure I was interpretting things correctly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2016 20:38:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Error-with-Proc-SGPLOT-Vbar-Response-and-categoryorder-respdesc/m-p/309145#M10851</guid>
      <dc:creator>sugiyama</dc:creator>
      <dc:date>2016-11-03T20:38:49Z</dc:date>
    </item>
    <item>
      <title>Re: Error with Proc SGPLOT, Vbar, Response, and categoryorder=respdesc;</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Error-with-Proc-SGPLOT-Vbar-Response-and-categoryorder-respdesc/m-p/309147#M10852</link>
      <description>&lt;P&gt;Can you post your full log?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And some sample data and a pic of the graph you're trying to achieve. I'm not good at visualizing graphs without a template.&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2016 20:55:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Error-with-Proc-SGPLOT-Vbar-Response-and-categoryorder-respdesc/m-p/309147#M10852</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-11-03T20:55:45Z</dc:date>
    </item>
    <item>
      <title>Re: Error with Proc SGPLOT, Vbar, Response, and categoryorder=respdesc;</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Error-with-Proc-SGPLOT-Vbar-Response-and-categoryorder-respdesc/m-p/309148#M10853</link>
      <description>&lt;P&gt;And what version of SAS are you testing this on to get your error?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2016 20:59:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Error-with-Proc-SGPLOT-Vbar-Response-and-categoryorder-respdesc/m-p/309148#M10853</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-11-03T20:59:00Z</dc:date>
    </item>
    <item>
      <title>Re: Error with Proc SGPLOT, Vbar, Response, and categoryorder=respdesc;</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Error-with-Proc-SGPLOT-Vbar-Response-and-categoryorder-respdesc/m-p/309152#M10854</link>
      <description>&lt;P&gt;Actually, RESPONSE is not required for CATEGORYORDER to work. Try these two simple programs and see if they work for you:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=sashelp.class;
vbar age / categoryorder=respdesc;
run;

proc sgplot data=sashelp.class;
vbar age / categoryorder=respdesc response=weight stat=mean;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;I agree with Reeza that some sample data and/or the PROC CONTENTS output would be helpful, as it sounds like a data issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;
&lt;P&gt;Dan&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2016 21:20:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Error-with-Proc-SGPLOT-Vbar-Response-and-categoryorder-respdesc/m-p/309152#M10854</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2016-11-03T21:20:17Z</dc:date>
    </item>
    <item>
      <title>Re: Error with Proc SGPLOT, Vbar, Response, and categoryorder=respdesc;</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Error-with-Proc-SGPLOT-Vbar-Response-and-categoryorder-respdesc/m-p/309266#M10859</link>
      <description>&lt;P&gt;In addition to Dan's example, see the article &lt;A href="http://blogs.sas.com/content/graphicallyspeaking/2012/06/07/bar-chart-with-response-sort/" target="_self"&gt;"Bar chart with response sort"&lt;/A&gt;. &amp;nbsp;The &lt;A href="http://blogs.sas.com/content/graphicallyspeaking/" target="_self"&gt;Graphically Speaking&lt;/A&gt;&amp;nbsp;blog has other examples, which you can see by typing&amp;nbsp;&lt;/P&gt;
&lt;P&gt;CATEGORYORDER&lt;/P&gt;
&lt;P&gt;into the search box on the blog.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2016 13:47:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Error-with-Proc-SGPLOT-Vbar-Response-and-categoryorder-respdesc/m-p/309266#M10859</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2016-11-04T13:47:51Z</dc:date>
    </item>
    <item>
      <title>Re: Error with Proc SGPLOT, Vbar, Response, and categoryorder=respdesc;</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Error-with-Proc-SGPLOT-Vbar-Response-and-categoryorder-respdesc/m-p/309398#M10866</link>
      <description>&lt;P&gt;Thank for the responses. I have done some more testing. The appears to be related to the fact that the variable that I am using has a user defined format associated with it. Below is the graph before I attempt to graph the bars from high to low based on the average math scores by country.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/5661i0536EFFEC8E358A3/image-size/medium?v=v2&amp;amp;px=-1" border="0" alt="SGPlot11.png" title="SGPlot11.png" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I add the categoryorder option, I get this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/5662i14954D1887305C05/image-size/medium?v=v2&amp;amp;px=-1" border="0" alt="SGPlot13.png" title="SGPlot13.png" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the warning message I get:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/5663i0D2CF1A9649694C4/image-size/medium?v=v2&amp;amp;px=-1" border="0" alt="sgplot problem Log warning.jpg" title="sgplot problem Log warning.jpg" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now it turns out that my CNT variable in my data set has a format associated with it: $CNTF. (I have to read in the formats to be able to do the first graph.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I add a format statement "format cnt $cntf." in my procedure then the categoryorder works fine.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc sgplot data=two ;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;vbar cnt / response=pv1math stat=mean categoryorder=respdesc;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;format cnt $cntf.;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is strange that without the categoryorder option and a response variable, everything is fine, and I don't need a format statement. When I do the exact same thing but add the categoryorder I get problems.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I have checked examples of sgplot and vbar with categoryorder, I believe there were no formats involved.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have attached my code, log, and output in pdf files if anyone is curious. It has a proc contents, proc print, and the format definitions that apply to my problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2016 20:00:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Error-with-Proc-SGPLOT-Vbar-Response-and-categoryorder-respdesc/m-p/309398#M10866</guid>
      <dc:creator>sugiyama</dc:creator>
      <dc:date>2016-11-04T20:00:52Z</dc:date>
    </item>
    <item>
      <title>Re: Error with Proc SGPLOT, Vbar, Response, and categoryorder=respdesc;</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/Error-with-Proc-SGPLOT-Vbar-Response-and-categoryorder-respdesc/m-p/309409#M10869</link>
      <description>&lt;P&gt;Do you have a quit after your sgplot and gplot procs?&lt;/P&gt;
&lt;P&gt;Also, is the format already applied on your dataset?&lt;/P&gt;
&lt;P&gt;Otherwise I don't see it used anywhere else...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Nov 2016 20:33:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/Error-with-Proc-SGPLOT-Vbar-Response-and-categoryorder-respdesc/m-p/309409#M10869</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2016-11-04T20:33:45Z</dc:date>
    </item>
  </channel>
</rss>

