<?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 Need help in specifying the order of bars in a bar graph (proc sgplot and proc sgpanel) in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Need-help-in-specifying-the-order-of-bars-in-a-bar-graph-proc/m-p/767260#M243224</link>
    <description>&lt;P&gt;I'm trying to make a bar chart where I can specify the order of X_A X_B and so on.&lt;/P&gt;&lt;P&gt;It looks like the default is alphabetical order.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would also like to reorder the bars as well; such as the order of E, Q, R, T, U, W.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2021-09-12 at 10.12.45 AM.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/63522iF2EFF52230B95CA2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screen Shot 2021-09-12 at 10.12.45 AM.png" alt="Screen Shot 2021-09-12 at 10.12.45 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods graphics / width=10in height=5in;

title '[P]in X';
proc sgplot data=Narwhal.Narwhal_Data (where=(Dependant_V Contains 'X'));
  vbar Dependant_V / response=N_Concentration group=Experiment_Group groupdisplay=cluster 
    stat=mean limitstat=clm;
  xaxis /*display=(nolabel noticks)*/ label="Package";
  yaxis grid label="Concentration (pines/apples)";
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;</description>
    <pubDate>Sun, 12 Sep 2021 14:17:50 GMT</pubDate>
    <dc:creator>Kedarnath_M</dc:creator>
    <dc:date>2021-09-12T14:17:50Z</dc:date>
    <item>
      <title>Need help in specifying the order of bars in a bar graph (proc sgplot and proc sgpanel)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-in-specifying-the-order-of-bars-in-a-bar-graph-proc/m-p/767260#M243224</link>
      <description>&lt;P&gt;I'm trying to make a bar chart where I can specify the order of X_A X_B and so on.&lt;/P&gt;&lt;P&gt;It looks like the default is alphabetical order.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would also like to reorder the bars as well; such as the order of E, Q, R, T, U, W.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2021-09-12 at 10.12.45 AM.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/63522iF2EFF52230B95CA2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Screen Shot 2021-09-12 at 10.12.45 AM.png" alt="Screen Shot 2021-09-12 at 10.12.45 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;ods graphics / width=10in height=5in;

title '[P]in X';
proc sgplot data=Narwhal.Narwhal_Data (where=(Dependant_V Contains 'X'));
  vbar Dependant_V / response=N_Concentration group=Experiment_Group groupdisplay=cluster 
    stat=mean limitstat=clm;
  xaxis /*display=(nolabel noticks)*/ label="Package";
  yaxis grid label="Concentration (pines/apples)";
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Sun, 12 Sep 2021 14:17:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-in-specifying-the-order-of-bars-in-a-bar-graph-proc/m-p/767260#M243224</guid>
      <dc:creator>Kedarnath_M</dc:creator>
      <dc:date>2021-09-12T14:17:50Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in specifying the order of bars in a bar graph (proc sgplot and proc sgpanel)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-in-specifying-the-order-of-bars-in-a-bar-graph-proc/m-p/767266#M243228</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/296956"&gt;@Kedarnath_M&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;On the xaxis - statement you need the&lt;/P&gt;
&lt;DIV class="xisDoc-refProc"&gt;
&lt;DIV class="xisDoc-refBlock"&gt;
&lt;DIV class="xisDoc-syntax"&gt;
&lt;DIV class="xisDoc-syntaxDescription"&gt;
&lt;DIV class="xisDoc-optionalArgGroup"&gt;
&lt;DIV id="n09f4ln7jq8gkan1w2nhlkzjcrqza" class="xisDoc-argDescriptionPair"&gt;
&lt;DIV class="xisDoc-argumentDescription"&gt;
&lt;UL class="xisDoc-listUnordered"&gt;
&lt;LI class="xisDoc-item"&gt;VALUES=(&lt;EM class="xisDoc-userSuppliedValue"&gt;“string-list”&lt;/EM&gt; ) specifies tick values for discrete axes. The values can be character or numeric.&lt;/LI&gt;
&lt;/UL&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or on the VBAR statement you need the&amp;nbsp;&lt;/P&gt;
&lt;UL class="lia-list-style-type-disc"&gt;
&lt;LI&gt;CATEGORYORDER=RESPASC(ending) | RESPDESC(ending) specifies the order in which the categories are arranged.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Good luck,&lt;/P&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Sun, 12 Sep 2021 16:19:24 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-in-specifying-the-order-of-bars-in-a-bar-graph-proc/m-p/767266#M243228</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-09-12T16:19:24Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in specifying the order of bars in a bar graph (proc sgplot and proc sgpanel)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-in-specifying-the-order-of-bars-in-a-bar-graph-proc/m-p/767280#M243238</link>
      <description>Sweet thank you Koen&lt;span class="lia-unicode-emoji" title=":thumbs_up:"&gt;👍&lt;/span&gt;&lt;BR /&gt;I tried the Categoryorder= option and its pretty cool I may use that as well, but is there a way to specify the order of the categories manually?</description>
      <pubDate>Sun, 12 Sep 2021 19:41:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-in-specifying-the-order-of-bars-in-a-bar-graph-proc/m-p/767280#M243238</guid>
      <dc:creator>Kedarnath_M</dc:creator>
      <dc:date>2021-09-12T19:41:28Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in specifying the order of bars in a bar graph (proc sgplot and proc sgpanel)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-in-specifying-the-order-of-bars-in-a-bar-graph-proc/m-p/767282#M243240</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;with the VALUES=(“string-list”) option on the xaxis statement:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=sashelp.heart;
  vbar smoking_status /
    response=ageatdeath
    stat=mean;
run;

proc sgplot data=sashelp.heart;
  vbar smoking_status /
    response=ageatdeath
    stat=mean
    datalabel=Smoking_Status;
&lt;U&gt;&lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;xaxis values=("Moderate (6-15)" "Non-smoker" "Heavy (16-25)" "Very Heavy (&amp;gt; 25)");&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/U&gt;
run;
/* end of program */&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Koen&lt;/P&gt;</description>
      <pubDate>Sun, 12 Sep 2021 19:58:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-in-specifying-the-order-of-bars-in-a-bar-graph-proc/m-p/767282#M243240</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2021-09-12T19:58:15Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in specifying the order of bars in a bar graph (proc sgplot and proc sgpanel)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-in-specifying-the-order-of-bars-in-a-bar-graph-proc/m-p/767284#M243241</link>
      <description>&lt;P&gt;My bad should have specified; I got the first part with the Value= option&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;title '[P]in X';
proc sgplot data=Narwhal.Narwhal_Data (where=(Location Contains 'X'));
  vbar Dependant_V / response=N_Concentration group=Experiment_Group groupdisplay=cluster 
    stat=mean limitstat=clm alpha=.05 ;
  xaxis /*display=(nolabel noticks)*/ label="Package" 
  values=('X_A' 'X_C' 'X_D' 'X_E' 'X_B' 'X_F');
  yaxis grid label="Concentration (pines/apples)";
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I meant for the second part where I can control the order of Q W E R T U Experimental_Group Variable order manually. This is without using the Categoryorder= option since that option orders the groups by itslef.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2021-09-12 at 4.09.04 PM.png" style="width: 200px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/63524i2A991C68624FB486/image-size/small?v=v2&amp;amp;px=200" role="button" title="Screen Shot 2021-09-12 at 4.09.04 PM.png" alt="Screen Shot 2021-09-12 at 4.09.04 PM.png" /&gt;&lt;/span&gt;&amp;nbsp;the part circled in red&lt;/P&gt;</description>
      <pubDate>Sun, 12 Sep 2021 20:14:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-in-specifying-the-order-of-bars-in-a-bar-graph-proc/m-p/767284#M243241</guid>
      <dc:creator>Kedarnath_M</dc:creator>
      <dc:date>2021-09-12T20:14:37Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in specifying the order of bars in a bar graph (proc sgplot and proc sgpanel)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-in-specifying-the-order-of-bars-in-a-bar-graph-proc/m-p/767390#M243285</link>
      <description>&lt;P&gt;Padding some blank before it.&lt;/P&gt;
&lt;PRE&gt;data have;
length Dependant_V $ 80 ;
set Narwhal.Narwhal_Data;
if Dependant_V='E' then Dependant_V ='          E';
if Dependant_V='Q' then Dependant_V ='      Q';
if Dependant_V='R' then Dependant_V ='   R';
run;
title '[P]in X';
proc sgplot data=have (where=(Dependant_V Contains 'X'));&lt;/PRE&gt;</description>
      <pubDate>Mon, 13 Sep 2021 12:25:47 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-in-specifying-the-order-of-bars-in-a-bar-graph-proc/m-p/767390#M243285</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2021-09-13T12:25:47Z</dc:date>
    </item>
    <item>
      <title>Re: Need help in specifying the order of bars in a bar graph (proc sgplot and proc sgpanel)</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Need-help-in-specifying-the-order-of-bars-in-a-bar-graph-proc/m-p/767715#M243431</link>
      <description>&lt;P&gt;Thank you Koen and KSharp! that worked&amp;nbsp;&lt;/P&gt;&lt;P&gt;At first I was confused because the letters wouldn't show up in the work.have data set at first. The length statement should have allowed there to be more characters in the column. When I ran proc contents I saw the format allowed only one character and so I had to go in and change that. I'm still new to SAS&lt;span class="lia-unicode-emoji" title=":grinning_face_with_sweat:"&gt;😅&lt;/span&gt;.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data work.have;
length Experiment_Group $ 10;
format Experiment_Group $ char10.;
set Narwhal.Narwhal_Data;
if Experiment_Group='Q' then Experiment_Group='     Q';
if Experiment_Group='W' then Experiment_Group='    W';
if Experiment_Group='E' then Experiment_Group='   E';
if Experiment_Group='R' then Experiment_Group='  R';
if Experiment_Group='T' then Experiment_Group=' T';
if Experiment_Group='U' then Experiment_Group='U';
run;

PROC CONTENTS DATA=have;

/* Open the LISTING destination and assign the LISTING style to the graph */
*ods listing style=listing;
ods graphics / width=10in height=5in;

title '[P]in X';
proc sgplot data=work.have (where=(Dependant_V Contains 'X'));
  vbar Dependant_V / response=N_Concentration group=Experiment_Group groupdisplay=cluster 
    stat=mean limitstat=clm;
  xaxis /*display=(nolabel noticks)*/ label="Package"
  values=('X_A' 'X_C' 'X_D' 'X_E' 'X_B' 'X_F');
  yaxis grid label="Concentration (pines/apples)";
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2021-09-14 at 9.55.50 AM.png" style="width: 510px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/63572iCF799941989E3F42/image-dimensions/510x261?v=v2" width="510" height="261" role="button" title="Screen Shot 2021-09-14 at 9.55.50 AM.png" alt="Screen Shot 2021-09-14 at 9.55.50 AM.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Sep 2021 14:03:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Need-help-in-specifying-the-order-of-bars-in-a-bar-graph-proc/m-p/767715#M243431</guid>
      <dc:creator>Kedarnath_M</dc:creator>
      <dc:date>2021-09-14T14:03:22Z</dc:date>
    </item>
  </channel>
</rss>

