<?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: proc sgplot: bars sorted by formatted values while using discreteorder=unformatted! in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/proc-sgplot-bars-sorted-by-formatted-values-while-using/m-p/939990#M24961</link>
    <description>&lt;P&gt;Given that discreteorder= is partially working and that it is also possible to define the order of the bars using values=, could it be that the statement in the online document is an old statement which was just not updated?&lt;/P&gt;</description>
    <pubDate>Mon, 19 Aug 2024 20:02:44 GMT</pubDate>
    <dc:creator>xxformat_com</dc:creator>
    <dc:date>2024-08-19T20:02:44Z</dc:date>
    <item>
      <title>proc sgplot: bars sorted by formatted values while using discreteorder=unformatted!</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/proc-sgplot-bars-sorted-by-formatted-values-while-using/m-p/939908#M24950</link>
      <description>&lt;P&gt;I'm wondering why we get the same result with both discreteorder=unformatted and discreteorder=formatted.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With unformatted I would have expect something like&lt;/P&gt;
&lt;P&gt;2-Female (F), 1-Male (M) and 3-Missing (X)&lt;/P&gt;
&lt;P&gt;not&lt;/P&gt;
&lt;P&gt;1-Male (M), 2-Female (F), 3-Missing (X)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
    value $sex 'F' = '2-Female'
               'M' = '1-Male'
               'X' = '3-Missing';
run;

data class;
    set sashelp.class;
    if age=13 then sex='X';
run;

*format statement only;
title 'discreteorder=unformatted';
proc sgplot data=class;
    vbarbasic sex / group=sex;
    format sex $sex.;
    xaxis discreteorder=unformatted;
run;


title 'discreteorder=formatted';
proc sgplot data=class;
    vbarbasic sex / group=sex;
    format sex $sex.;
    xaxis discreteorder=formatted;
run;
title;



&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;with valuesformat= it would work as expected&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;title 'discreteorder=unformatted';
proc sgplot data=class;
    vbarbasic sex / group=sex;
    xaxis discreteorder=unformatted valuesformat=$sex.;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 19 Aug 2024 15:39:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/proc-sgplot-bars-sorted-by-formatted-values-while-using/m-p/939908#M24950</guid>
      <dc:creator>xxformat_com</dc:creator>
      <dc:date>2024-08-19T15:39:00Z</dc:date>
    </item>
    <item>
      <title>Re: proc sgplot: bars sorted by formatted values while using discreteorder=unformatted!</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/proc-sgplot-bars-sorted-by-formatted-values-while-using/m-p/939914#M24951</link>
      <description>&lt;P&gt;Did you by any chance compare the results of VBAR and VBARBASIC?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you check the documentation you will find this:&lt;/P&gt;
&lt;BLOCKQUOTE&gt;
&lt;DIV class="xisDoc-refProc"&gt;
&lt;DIV class="xisDoc-refBlock"&gt;
&lt;SECTION class="xisDoc-tableWrap"&gt;
&lt;TABLE class="xisDoc-summary"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD class="xisDoc-summaryText"&gt;The bars are sorted in data order based on the category values. The sort order cannot be changed. This arrangement of the bars differs from the VBAR statement, which by default sorts bars in alphabetical order based on the category values.&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;/SECTION&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Which looks to me like Unformatted and Formatted may be treated similarly without additional instructions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2024 16:04:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/proc-sgplot-bars-sorted-by-formatted-values-while-using/m-p/939914#M24951</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2024-08-19T16:04:28Z</dc:date>
    </item>
    <item>
      <title>Re: proc sgplot: bars sorted by formatted values while using discreteorder=unformatted!</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/proc-sgplot-bars-sorted-by-formatted-values-while-using/m-p/939920#M24952</link>
      <description>&lt;P&gt;ADVICE (which I know you didn't ask for)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Using '1-Male' to represent 'Male' and '2-Female' to represent 'Female' and '3-Missing' to represent 'Missing" is not a good practice in my opinion, it looks unprofessional and adds things onto the plot that do not increase the understanding of what the plot is showing. The viewers of the plot (your colleagues or your professor or your boss or perhaps even potential customers) don't need to know that inside your program you used the number 2 so you can have Female in the 2nd position. Better practice is to use 'Male' to represent 'Male' and so on, and use other tools to make the ordering of the values what you want. Example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc format;
    value $sex 'F' = 'Female'
               'M' = 'Male'
               'X' = 'Missing';
run;

data class1;
    set sashelp.class;
    if age=13 then do; order=3; sex='X'; end;
    else if sex='F' then order=2;
    else if sex='M' then order=1;
run;

proc sort data=class1;
    by order;
run;

proc sgplot data=class1;
    vbar sex / group=sex;
    format sex $sex.;
    xaxis discreteorder=data;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&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="PaigeMiller_0-1724084462295.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/99408i55D45A7062635A96/image-size/medium?v=v2&amp;amp;px=400" role="button" title="PaigeMiller_0-1724084462295.png" alt="PaigeMiller_0-1724084462295.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this case, you can also maximize people's ability to read your plot by turning off the legend, which is redundant now.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2024 16:21:36 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/proc-sgplot-bars-sorted-by-formatted-values-while-using/m-p/939920#M24952</guid>
      <dc:creator>PaigeMiller</dc:creator>
      <dc:date>2024-08-19T16:21:36Z</dc:date>
    </item>
    <item>
      <title>Re: proc sgplot: bars sorted by formatted values while using discreteorder=unformatted!</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/proc-sgplot-bars-sorted-by-formatted-values-while-using/m-p/939923#M24953</link>
      <description>&lt;P&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13884"&gt;@ballardw&lt;/a&gt;&amp;nbsp;is correct -- the DISCRETEORDER option will not work with VBARBASIC/HBARBASIC.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As a general principle, the VBAR statement should be favored over the VBARBASIC statement, except for two notable situations:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;You want to overlay a plot on top of the bar chart that is not allowed by the VBAR statement. If you compute the statistics outside of SGPLOT, you would normally use a VBARPARM statement for this situation. However, if the statistics are simple (freq, sum , and mean), VBARBASIC is a good statement to use instead of having to do a separate compute step.&lt;/LI&gt;
&lt;LI&gt;You want to overlay a non-grouped line chart on a grouped bar chart. For this situation, you would normally compute the statistics outside of SGPLOT and use a SERIES and a VBARPARM. However, using VBABASIC might save you one compute step.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Hope this helps!&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2024 16:36:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/proc-sgplot-bars-sorted-by-formatted-values-while-using/m-p/939923#M24953</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2024-08-19T16:36:04Z</dc:date>
    </item>
    <item>
      <title>Re: proc sgplot: bars sorted by formatted values while using discreteorder=unformatted!</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/proc-sgplot-bars-sorted-by-formatted-values-while-using/m-p/939933#M24954</link>
      <description>Hi Paige, it is just a sample code to illustrate the sorting issue, not the final output where a first format can be used to define the sorting order and a second one in valuesformat to define the values displayed on the axis.</description>
      <pubDate>Mon, 19 Aug 2024 17:16:19 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/proc-sgplot-bars-sorted-by-formatted-values-while-using/m-p/939933#M24954</guid>
      <dc:creator>xxformat_com</dc:creator>
      <dc:date>2024-08-19T17:16:19Z</dc:date>
    </item>
    <item>
      <title>Re: proc sgplot: bars sorted by formatted values while using discreteorder=unformatted!</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/proc-sgplot-bars-sorted-by-formatted-values-while-using/m-p/939937#M24956</link>
      <description>&lt;P&gt;Would you consider writing a great blog post on when to use vbar, vbarparm and vbarbasic?&lt;/P&gt;
&lt;P&gt;I find it so badly documented.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Somehow I came accross issues with vbar and statements like vbar is mainly following the old proc gchart approach and decided to go for vbarbasic everywhere (which costs me hours of work to update things) in my code and documentation due to that :(. I really don't feel like going back to vbar now and it would be great other people won't face the same issue. Before today, the only issue I had with vbarbasic was the fact that limits options are not available there for some reason.&lt;BR /&gt;&lt;BR /&gt;ps. As far as I can remember options like tip= are more intuitive with vbarbasic than vbar. vbar are a lot of options which are only there to compute the statistics in the same procedure as the plot. During the development having to recompute each time the statistics to generate the plot does not really appeal to me. So I don't really value this additional feature of vbar. What other feature of vbar would be valuable and not available in vbarparm/vbarbasic? I'm not sure.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2024 17:38:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/proc-sgplot-bars-sorted-by-formatted-values-while-using/m-p/939937#M24956</guid>
      <dc:creator>xxformat_com</dc:creator>
      <dc:date>2024-08-19T17:38:44Z</dc:date>
    </item>
    <item>
      <title>Re: proc sgplot: bars sorted by formatted values while using discreteorder=unformatted!</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/proc-sgplot-bars-sorted-by-formatted-values-while-using/m-p/939939#M24957</link>
      <description>&lt;P&gt;ps. it works on some occasions with vbarbasic even if the documentation does not support it e.g. there is a difference when discreteorder=data and discreteorder=unformatted when no format is used.&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2024 17:28:57 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/proc-sgplot-bars-sorted-by-formatted-values-while-using/m-p/939939#M24957</guid>
      <dc:creator>xxformat_com</dc:creator>
      <dc:date>2024-08-19T17:28:57Z</dc:date>
    </item>
    <item>
      <title>Re: proc sgplot: bars sorted by formatted values while using discreteorder=unformatted!</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/proc-sgplot-bars-sorted-by-formatted-values-while-using/m-p/939941#M24958</link>
      <description>&lt;P&gt;Thanks ballard, I didn't see that.&lt;/P&gt;
&lt;P&gt;I wish it would better documented in the xaxis statment page by the discreteorder= option .&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2024 17:28:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/proc-sgplot-bars-sorted-by-formatted-values-while-using/m-p/939941#M24958</guid>
      <dc:creator>xxformat_com</dc:creator>
      <dc:date>2024-08-19T17:28:17Z</dc:date>
    </item>
    <item>
      <title>Re: proc sgplot: bars sorted by formatted values while using discreteorder=unformatted!</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/proc-sgplot-bars-sorted-by-formatted-values-while-using/m-p/939945#M24959</link>
      <description>&lt;P&gt;I'll see if I can put something together.&lt;/P&gt;
&lt;P&gt;You mentioned that you had issues with the VBAR/HBAR statements. What kind of issues were you having?&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2024 17:44:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/proc-sgplot-bars-sorted-by-formatted-values-while-using/m-p/939945#M24959</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2024-08-19T17:44:14Z</dc:date>
    </item>
    <item>
      <title>Re: proc sgplot: bars sorted by formatted values while using discreteorder=unformatted!</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/proc-sgplot-bars-sorted-by-formatted-values-while-using/m-p/939952#M24960</link>
      <description>I cannot remember. That's already a few years ago. If I do find it again, I'll let you know.</description>
      <pubDate>Mon, 19 Aug 2024 17:54:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/proc-sgplot-bars-sorted-by-formatted-values-while-using/m-p/939952#M24960</guid>
      <dc:creator>xxformat_com</dc:creator>
      <dc:date>2024-08-19T17:54:26Z</dc:date>
    </item>
    <item>
      <title>Re: proc sgplot: bars sorted by formatted values while using discreteorder=unformatted!</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/proc-sgplot-bars-sorted-by-formatted-values-while-using/m-p/939990#M24961</link>
      <description>&lt;P&gt;Given that discreteorder= is partially working and that it is also possible to define the order of the bars using values=, could it be that the statement in the online document is an old statement which was just not updated?&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2024 20:02:44 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/proc-sgplot-bars-sorted-by-formatted-values-while-using/m-p/939990#M24961</guid>
      <dc:creator>xxformat_com</dc:creator>
      <dc:date>2024-08-19T20:02:44Z</dc:date>
    </item>
  </channel>
</rss>

