<?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: Histogram bar labels in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Histogram-bar-labels/m-p/767875#M243499</link>
    <description>&lt;P&gt;Is there a way to do this in SGPLOT?&lt;/P&gt;</description>
    <pubDate>Wed, 15 Sep 2021 12:03:10 GMT</pubDate>
    <dc:creator>mariko5797</dc:creator>
    <dc:date>2021-09-15T12:03:10Z</dc:date>
    <item>
      <title>Histogram bar labels</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Histogram-bar-labels/m-p/540319#M149026</link>
      <description>&lt;P&gt;Dear SAS experts,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to create a histogram with PROC UNIVARIATE:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc univariate data=data1 noprint;&lt;/P&gt;&lt;P&gt;class hiv47;&lt;/P&gt;&lt;P&gt;histogram depression_cat/ normal midpoints=0 1 2 3 4 5 nrows=2 barlabel=percent;&lt;/P&gt;&lt;P&gt;inset n='Number of participants' median mean std='SD'/ position=ne;&lt;/P&gt;&lt;P&gt;label hiv47="HIV"&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; depression_cat="depression categories";&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It created the histogram, but is it possible to relabel each bar category, so I can use text for each bar instead of 0 1 2 3 4 5?&lt;/P&gt;&lt;P&gt;For example, 0=no depression, 1=minimal depression, 2=mild depression, etc....&amp;nbsp;&lt;/P&gt;&lt;P&gt;I checked options for proc univariate but did not seem to find a good solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, is it possible to color code each bar by gender using proc univariate? For example, female proportion appears red while male proportion appears blue in each bar?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you all in advance for any advice!&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2019 04:42:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Histogram-bar-labels/m-p/540319#M149026</guid>
      <dc:creator>michan22</dc:creator>
      <dc:date>2019-03-05T04:42:23Z</dc:date>
    </item>
    <item>
      <title>Re: Histogram bar labels</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Histogram-bar-labels/m-p/540327#M149030</link>
      <description>&lt;P&gt;Use a format, as in:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data heart;
set sashelp.heart;
agegrp = round(ageAtStart, 10);
run;

proc sql;
create table ageGrp as
select unique
    "ageGrp" as fmtname,
    ageGrp as start,
    cats("*", ageGrp, "*") as label
from heart;
quit;

proc format cntlin=ageGrp; run;

proc univariate data=heart;
class sex;
var ageGrp;
format ageGrp ageGrp.;
histogram ageGrp / normal midpoints=30 40 50 60 barlabel=percent;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Histogram.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/27664i501F00376647FCFA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Histogram.png" alt="Histogram.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2019 05:13:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Histogram-bar-labels/m-p/540327#M149030</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-03-05T05:13:33Z</dc:date>
    </item>
    <item>
      <title>Re: Histogram bar labels</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Histogram-bar-labels/m-p/542957#M150068</link>
      <description>&lt;P&gt;Thank you&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/462"&gt;@PGStats&lt;/a&gt;&amp;nbsp;for your wonderful advice as always.&lt;/P&gt;&lt;P&gt;So I specified the format in PROC FORMAT instead of SQL and the labels were not under the correct bar (see attached graph). Is this problem due to the length of characters for each category?&lt;/P&gt;</description>
      <pubDate>Wed, 13 Mar 2019 21:59:38 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Histogram-bar-labels/m-p/542957#M150068</guid>
      <dc:creator>michan22</dc:creator>
      <dc:date>2019-03-13T21:59:38Z</dc:date>
    </item>
    <item>
      <title>Re: Histogram bar labels</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Histogram-bar-labels/m-p/543002#M150087</link>
      <description>&lt;P&gt;The labels look placed correctly but they have been thinned out. With UNIVARIATE, your only option is to make them shorter (abbreviations). SG procedures are more flexible, they let you specify a different label fit policy in such situations.&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2019 03:55:45 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Histogram-bar-labels/m-p/543002#M150087</guid>
      <dc:creator>PGStats</dc:creator>
      <dc:date>2019-03-14T03:55:45Z</dc:date>
    </item>
    <item>
      <title>Re: Histogram bar labels</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Histogram-bar-labels/m-p/543199#M150146</link>
      <description>&lt;P&gt;Thank you!&amp;nbsp;&lt;/P&gt;&lt;P&gt;By SG you mean PROC SGPLOT? I will look into this procedure more&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2019 15:10:49 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Histogram-bar-labels/m-p/543199#M150146</guid>
      <dc:creator>michan22</dc:creator>
      <dc:date>2019-03-14T15:10:49Z</dc:date>
    </item>
    <item>
      <title>Re: Histogram bar labels</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Histogram-bar-labels/m-p/767875#M243499</link>
      <description>&lt;P&gt;Is there a way to do this in SGPLOT?&lt;/P&gt;</description>
      <pubDate>Wed, 15 Sep 2021 12:03:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Histogram-bar-labels/m-p/767875#M243499</guid>
      <dc:creator>mariko5797</dc:creator>
      <dc:date>2021-09-15T12:03:10Z</dc:date>
    </item>
  </channel>
</rss>

