<?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 How to align group labels of the hbar in sgplot, and remove space between hbars and labels in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/How-to-align-group-labels-of-the-hbar-in-sgplot-and-remove-space/m-p/772266#M22096</link>
    <description>&lt;P&gt;&lt;STRONG&gt;Hello,&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;I am using proc sgplot code below to make this graph. However, I would like the group labels to be left-aligned, and the bars to be close to the group labels (now there is a space). Also, it would be desirable to move the group data values of the hbar a little away from the bars so that they are more readable. I use sas v9.4 (TS1M4).&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Your help is appreciated.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;sgplot&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;styleattrs datacontrastcolors=(very_dark_blue dark_red)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; datacolors=(greenish_Blue "vivid yellowish brown")&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; datalinepatterns=(solid);&lt;/P&gt;
&lt;P&gt;hbarparm category=region3 response=colpercent / group=periodontitis4 grouporder=ascending&lt;/P&gt;
&lt;P&gt;&amp;nbsp; datalabel name='bar' dataskin=crisp;&lt;/P&gt;
&lt;P&gt;scatter x=totpercent y=region3 / markerchar=totpercent&lt;/P&gt;
&lt;P&gt;&amp;nbsp; markercharattrs=(size=&lt;STRONG&gt;14&lt;/STRONG&gt; weight=bold) name='scatter';&lt;/P&gt;
&lt;P&gt;xaxis discreteorder=data&lt;/P&gt;
&lt;P&gt;&amp;nbsp; label='% Subjects'&lt;/P&gt;
&lt;P&gt;&amp;nbsp; labelattrs=(size=&lt;STRONG&gt;16&lt;/STRONG&gt;pt weight=bold)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; valueattrs=(size=&lt;STRONG&gt;14&lt;/STRONG&gt;pt);&lt;/P&gt;
&lt;P&gt;yaxis grid label='Geographic Regions'&lt;/P&gt;
&lt;P&gt;&amp;nbsp; labelattrs=(size=&lt;STRONG&gt;20&lt;/STRONG&gt;pt weight=bold)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; valueattrs=(size=&lt;STRONG&gt;14&lt;/STRONG&gt;pt weight=bold)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; display=(noticks) ;&lt;/P&gt;
&lt;P&gt;keylegend 'bar' / location=inside position=topright&lt;/P&gt;
&lt;P&gt;&amp;nbsp; titleattrs=(weight=bold size=&lt;STRONG&gt;14&lt;/STRONG&gt;pt)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; valueattrs=(color=black size=&lt;STRONG&gt;14&lt;/STRONG&gt;pt)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; title=""&amp;nbsp; down=&lt;STRONG&gt;2&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;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Jason2020_0-1633462767027.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64379i5A56B99893727561/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Jason2020_0-1633462767027.png" alt="Jason2020_0-1633462767027.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 05 Oct 2021 19:42:55 GMT</pubDate>
    <dc:creator>Jason2020</dc:creator>
    <dc:date>2021-10-05T19:42:55Z</dc:date>
    <item>
      <title>How to align group labels of the hbar in sgplot, and remove space between hbars and labels</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-align-group-labels-of-the-hbar-in-sgplot-and-remove-space/m-p/772266#M22096</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Hello,&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;I am using proc sgplot code below to make this graph. However, I would like the group labels to be left-aligned, and the bars to be close to the group labels (now there is a space). Also, it would be desirable to move the group data values of the hbar a little away from the bars so that they are more readable. I use sas v9.4 (TS1M4).&lt;BR /&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Your help is appreciated.&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;proc&lt;/STRONG&gt; &lt;STRONG&gt;sgplot&lt;/STRONG&gt;;&lt;/P&gt;
&lt;P&gt;styleattrs datacontrastcolors=(very_dark_blue dark_red)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; datacolors=(greenish_Blue "vivid yellowish brown")&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; datalinepatterns=(solid);&lt;/P&gt;
&lt;P&gt;hbarparm category=region3 response=colpercent / group=periodontitis4 grouporder=ascending&lt;/P&gt;
&lt;P&gt;&amp;nbsp; datalabel name='bar' dataskin=crisp;&lt;/P&gt;
&lt;P&gt;scatter x=totpercent y=region3 / markerchar=totpercent&lt;/P&gt;
&lt;P&gt;&amp;nbsp; markercharattrs=(size=&lt;STRONG&gt;14&lt;/STRONG&gt; weight=bold) name='scatter';&lt;/P&gt;
&lt;P&gt;xaxis discreteorder=data&lt;/P&gt;
&lt;P&gt;&amp;nbsp; label='% Subjects'&lt;/P&gt;
&lt;P&gt;&amp;nbsp; labelattrs=(size=&lt;STRONG&gt;16&lt;/STRONG&gt;pt weight=bold)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; valueattrs=(size=&lt;STRONG&gt;14&lt;/STRONG&gt;pt);&lt;/P&gt;
&lt;P&gt;yaxis grid label='Geographic Regions'&lt;/P&gt;
&lt;P&gt;&amp;nbsp; labelattrs=(size=&lt;STRONG&gt;20&lt;/STRONG&gt;pt weight=bold)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; valueattrs=(size=&lt;STRONG&gt;14&lt;/STRONG&gt;pt weight=bold)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; display=(noticks) ;&lt;/P&gt;
&lt;P&gt;keylegend 'bar' / location=inside position=topright&lt;/P&gt;
&lt;P&gt;&amp;nbsp; titleattrs=(weight=bold size=&lt;STRONG&gt;14&lt;/STRONG&gt;pt)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; valueattrs=(color=black size=&lt;STRONG&gt;14&lt;/STRONG&gt;pt)&lt;/P&gt;
&lt;P&gt;&amp;nbsp; title=""&amp;nbsp; down=&lt;STRONG&gt;2&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;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Jason2020_0-1633462767027.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64379i5A56B99893727561/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Jason2020_0-1633462767027.png" alt="Jason2020_0-1633462767027.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Oct 2021 19:42:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-align-group-labels-of-the-hbar-in-sgplot-and-remove-space/m-p/772266#M22096</guid>
      <dc:creator>Jason2020</dc:creator>
      <dc:date>2021-10-05T19:42:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to align group labels of the hbar in sgplot, and remove space between hbars and labels</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-align-group-labels-of-the-hbar-in-sgplot-and-remove-space/m-p/772269#M22097</link>
      <description>&lt;P&gt;You are using a SCATTER plot overlay to display the totpercent values.&amp;nbsp; This causes the overlap on the values on the top of the bar.&amp;nbsp; This is also causing the extra space at the left near the y-axis.&amp;nbsp; You can use the DATALABEL=totpercent option on the HBARPARM itself and drop the SCATTER statement.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Oct 2021 19:55:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-align-group-labels-of-the-hbar-in-sgplot-and-remove-space/m-p/772269#M22097</guid>
      <dc:creator>Jay54</dc:creator>
      <dc:date>2021-10-05T19:55:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to align group labels of the hbar in sgplot, and remove space between hbars and labels</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-align-group-labels-of-the-hbar-in-sgplot-and-remove-space/m-p/772275#M22098</link>
      <description>I removed the SCATTER and added the DATALABEL=totpercent.&lt;BR /&gt;The extra space is now resolved. However, the total percent is not showing, and the group labels "Central, North West, etc" are not left-aligned. Anything I can do to correct the latter 2 issues?&lt;BR /&gt;Thanks.</description>
      <pubDate>Tue, 05 Oct 2021 20:15:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-align-group-labels-of-the-hbar-in-sgplot-and-remove-space/m-p/772275#M22098</guid>
      <dc:creator>Jason2020</dc:creator>
      <dc:date>2021-10-05T20:15:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to align group labels of the hbar in sgplot, and remove space between hbars and labels</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-align-group-labels-of-the-hbar-in-sgplot-and-remove-space/m-p/772305#M22099</link>
      <description>&lt;P&gt;The DATALABEL option did not work because the grouped bar chart is stacked (it would have worked for a "cluster" display). The best way to make this work for you is to use a TEXT plot (see the code below). There are options to adjust the text alignment and for disabling the text plot from contributing to the "min" offset. You want it to contribute to the other offsets so that there is no clipping.&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot;
styleattrs datacontrastcolors=(very_dark_blue dark_red)
   datacolors=(greenish_Blue "vivid yellowish brown")
   datalinepatterns=(solid);
hbarparm category=region3 response=colpercent / group=periodontitis4 grouporder=ascending
  datalabel name='bar' dataskin=crisp;
text x=totpercent y=region3 text=totpercent / position=right
  contributeoffsets=(xmax ymin ymax)
  textattrs=(size=14 weight=bold);
xaxis discreteorder=data
  label='% Subjects'
  labelattrs=(size=16pt weight=bold)
  valueattrs=(size=14pt);
yaxis grid label='Geographic Regions'
  labelattrs=(size=20pt weight=bold)
  valueattrs=(size=14pt weight=bold)
  display=(noticks) ;
keylegend 'bar' / location=inside position=topright
  titleattrs=(weight=bold size=14pt)
  valueattrs=(color=black size=14pt)
  title=""  down=2;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2021 13:45:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-align-group-labels-of-the-hbar-in-sgplot-and-remove-space/m-p/772305#M22099</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2021-10-06T13:45:17Z</dc:date>
    </item>
    <item>
      <title>Re: How to align group labels of the hbar in sgplot, and remove space between hbars and labels</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-align-group-labels-of-the-hbar-in-sgplot-and-remove-space/m-p/772413#M22101</link>
      <description>&lt;P&gt;Dan: Your solution worked nicely. The only change I made is to replace MARKERCHARATTRS with TEXTATTRS because it caused an error.&lt;BR /&gt;Thank you very much. The final graph is shown below.&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="Jason2020_0-1633524030633.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/64397iBFC4AE631345EC3E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Jason2020_0-1633524030633.png" alt="Jason2020_0-1633524030633.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2021 12:40:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-align-group-labels-of-the-hbar-in-sgplot-and-remove-space/m-p/772413#M22101</guid>
      <dc:creator>Jason2020</dc:creator>
      <dc:date>2021-10-06T12:40:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to align group labels of the hbar in sgplot, and remove space between hbars and labels</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-align-group-labels-of-the-hbar-in-sgplot-and-remove-space/m-p/772434#M22102</link>
      <description>&lt;P&gt;Sorry about not changing MARKERCHARATTRS to TEXTATTRS. I edited the solution for everyone's future reference. Thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2021 13:48:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-align-group-labels-of-the-hbar-in-sgplot-and-remove-space/m-p/772434#M22102</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2021-10-06T13:48:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to align group labels of the hbar in sgplot, and remove space between hbars and labels</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-align-group-labels-of-the-hbar-in-sgplot-and-remove-space/m-p/772567#M22107</link>
      <description>Dan,&lt;BR /&gt;One final question: I am placing two versions of this plot side by side, and therefore would like to remove the yaxis labels (valueattrs) "Central, North West, etc" from one of the 2 plots. Is there a way to do that? &lt;BR /&gt;&lt;BR /&gt;Jason</description>
      <pubDate>Wed, 06 Oct 2021 20:21:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-align-group-labels-of-the-hbar-in-sgplot-and-remove-space/m-p/772567#M22107</guid>
      <dc:creator>Jason2020</dc:creator>
      <dc:date>2021-10-06T20:21:37Z</dc:date>
    </item>
    <item>
      <title>Re: How to align group labels of the hbar in sgplot, and remove space between hbars and labels</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-align-group-labels-of-the-hbar-in-sgplot-and-remove-space/m-p/772587#M22108</link>
      <description>&lt;P&gt;The DISPLAY option you are using on your YAXIS statement supports up to four options inside the parentheses:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;NOTICKS - remove the tick mark lines&lt;/LI&gt;
&lt;LI&gt;NOVALUES - remove the tick value text&lt;/LI&gt;
&lt;LI&gt;NOLINE - remove the axis line&lt;/LI&gt;
&lt;LI&gt;NOLABEL - remove the axis label&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;DISPLAY=NONE removes everything. DISPLAY=ALL shows everything. Try these out to get the look you want. As an example, to remove the axis labels and values, you would do DISPLAY=(NOLABEL NOVALUES).&lt;/P&gt;</description>
      <pubDate>Wed, 06 Oct 2021 22:03:26 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-align-group-labels-of-the-hbar-in-sgplot-and-remove-space/m-p/772587#M22108</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2021-10-06T22:03:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to align group labels of the hbar in sgplot, and remove space between hbars and labels</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-align-group-labels-of-the-hbar-in-sgplot-and-remove-space/m-p/772693#M22109</link>
      <description>Great. Thank you very much&lt;BR /&gt;</description>
      <pubDate>Thu, 07 Oct 2021 11:57:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-align-group-labels-of-the-hbar-in-sgplot-and-remove-space/m-p/772693#M22109</guid>
      <dc:creator>Jason2020</dc:creator>
      <dc:date>2021-10-07T11:57:04Z</dc:date>
    </item>
  </channel>
</rss>

