<?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 SGPLOT Bar chart Xaxis labeling error in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/SGPLOT-Bar-chart-Xaxis-labeling-error/m-p/368836#M64998</link>
    <description>&lt;P&gt;I am trying to create a bar chart with the correct data labels. If I write my code like this:&lt;/P&gt;&lt;PRE&gt;DATA AgeChart; SET BCMasterSet2;
FORMAT AgeGroup;
IF missing(Age) then delete;
IF Age &amp;lt; 40 then AgeGroup = 39; ELSE IF (Age &amp;gt; 39 &amp;amp; Age &amp;lt; 50) then AgeGroup = 49;
ELSE IF (Age &amp;gt; 49 &amp;amp; Age &amp;lt; 60) then AgeGroup = 59; ELSE IF (Age &amp;gt; 59 &amp;amp; Age &amp;lt; 70) then AgeGroup = 69;
ELSE AgeGroup = 70;
KEEP Age AgeGroup;
RUN;

PROC SGPLOT DATA = AgeChart; 
/*xaxis values = ("&amp;lt;40" "40-49" "50-59" "60-69" "70&amp;gt;");*/
VBAR AgeGroup;
run;&lt;/PRE&gt;&lt;P&gt;I get the following chart:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/9548i522E54FCB259A98F/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="chart.jpg" title="chart.jpg" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I don't want the data labels as they are. I want them to say "&amp;lt;40", "40-49", "50-59", "60-69", and "70&amp;gt;".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I typed in the above code in order to get that, removing the comment feature out of the xaxis values statement, and this is what happens to my bar chart:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/9552iDB39DD31703CCFCE/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="messedupchart.jpg" title="messedupchart.jpg" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where did all my data go? Can someone help me fix this problem? Thank you!&lt;/P&gt;</description>
    <pubDate>Tue, 20 Jun 2017 17:53:38 GMT</pubDate>
    <dc:creator>lady8506</dc:creator>
    <dc:date>2017-06-20T17:53:38Z</dc:date>
    <item>
      <title>SGPLOT Bar chart Xaxis labeling error</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SGPLOT-Bar-chart-Xaxis-labeling-error/m-p/368836#M64998</link>
      <description>&lt;P&gt;I am trying to create a bar chart with the correct data labels. If I write my code like this:&lt;/P&gt;&lt;PRE&gt;DATA AgeChart; SET BCMasterSet2;
FORMAT AgeGroup;
IF missing(Age) then delete;
IF Age &amp;lt; 40 then AgeGroup = 39; ELSE IF (Age &amp;gt; 39 &amp;amp; Age &amp;lt; 50) then AgeGroup = 49;
ELSE IF (Age &amp;gt; 49 &amp;amp; Age &amp;lt; 60) then AgeGroup = 59; ELSE IF (Age &amp;gt; 59 &amp;amp; Age &amp;lt; 70) then AgeGroup = 69;
ELSE AgeGroup = 70;
KEEP Age AgeGroup;
RUN;

PROC SGPLOT DATA = AgeChart; 
/*xaxis values = ("&amp;lt;40" "40-49" "50-59" "60-69" "70&amp;gt;");*/
VBAR AgeGroup;
run;&lt;/PRE&gt;&lt;P&gt;I get the following chart:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/9548i522E54FCB259A98F/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="chart.jpg" title="chart.jpg" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I don't want the data labels as they are. I want them to say "&amp;lt;40", "40-49", "50-59", "60-69", and "70&amp;gt;".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I typed in the above code in order to get that, removing the comment feature out of the xaxis values statement, and this is what happens to my bar chart:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/9552iDB39DD31703CCFCE/image-size/original?v=1.0&amp;amp;px=-1" border="0" alt="messedupchart.jpg" title="messedupchart.jpg" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Where did all my data go? Can someone help me fix this problem? Thank you!&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jun 2017 17:53:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SGPLOT-Bar-chart-Xaxis-labeling-error/m-p/368836#M64998</guid>
      <dc:creator>lady8506</dc:creator>
      <dc:date>2017-06-20T17:53:38Z</dc:date>
    </item>
    <item>
      <title>Re: SGPLOT Bar chart Xaxis labeling error</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SGPLOT-Bar-chart-Xaxis-labeling-error/m-p/368906#M65005</link>
      <description>&lt;P&gt;See if this gets you close:&lt;/P&gt;
&lt;PRE&gt;proc format library=work;
value AgeGroup
0 - 39 = " &amp;lt;40"
40 - 49= "40-49"
50 - 59= "50-59"
60 - 69= "60-69"
70 - high="70&amp;gt;"
;
run;

proc sgplot data=Bcmasterset2;
   vbar age ;
   format age agegroup.;
   label age= 'Age Group';
run;&lt;/PRE&gt;
&lt;P&gt;You can use custom formats to create groups of values as well as supply text labels for them. I use them a lot because I can have multiple similar formats and apply as needed without creating addtional variables.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The issue is that XAXIS values you provided were character and did not match values of the actual age group variable.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jun 2017 19:21:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SGPLOT-Bar-chart-Xaxis-labeling-error/m-p/368906#M65005</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2017-06-20T19:21:15Z</dc:date>
    </item>
    <item>
      <title>Re: SGPLOT Bar chart Xaxis labeling error</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SGPLOT-Bar-chart-Xaxis-labeling-error/m-p/368936#M65007</link>
      <description>Perfect! You are a genius!</description>
      <pubDate>Tue, 20 Jun 2017 20:29:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SGPLOT-Bar-chart-Xaxis-labeling-error/m-p/368936#M65007</guid>
      <dc:creator>lady8506</dc:creator>
      <dc:date>2017-06-20T20:29:27Z</dc:date>
    </item>
    <item>
      <title>Re: SGPLOT Bar chart Xaxis labeling error</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/SGPLOT-Bar-chart-Xaxis-labeling-error/m-p/369136#M65021</link>
      <description>&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=sashelp.class;
vbar age;
xaxis values=('11' '12' '13' '14' '15' '16')  VALUESDISPLAY=("&amp;lt;40" "40-49" "50-59" "60-69" "70&amp;gt;" "sds");
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Jun 2017 13:29:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/SGPLOT-Bar-chart-Xaxis-labeling-error/m-p/369136#M65021</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-06-21T13:29:28Z</dc:date>
    </item>
  </channel>
</rss>

