<?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: HISTOGRAM. Need a bin for each category in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-HISTOGRAM-Need-a-bin-for-each-category/m-p/963028#M25392</link>
    <description>&lt;P&gt;The same result with an additional NOTE:&lt;/P&gt;
&lt;PRE&gt;NOTE: The specified BINWIDTH= value will be ignored in order to accommodate the data
&lt;/PRE&gt;</description>
    <pubDate>Mon, 31 Mar 2025 16:18:00 GMT</pubDate>
    <dc:creator>A_Kh</dc:creator>
    <dc:date>2025-03-31T16:18:00Z</dc:date>
    <item>
      <title>PROC SGPLOT: HISTOGRAM. Need a bin for each category</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-HISTOGRAM-Need-a-bin-for-each-category/m-p/963023#M25388</link>
      <description>&lt;P&gt;Hello Community,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm having difficulty in creating a bin for each category of the histogram. The problem is one of the response categories has relatively small frequency and when using the sgplot procedure I couldn't create a bin for that category. The SAS Documentation I could find was not helpful enough to solve this issue. I would appreciate your support.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Below is an example using sashelp.cars data. &lt;BR /&gt;&lt;BR /&gt;Trying 2 different ways:&lt;BR /&gt;1. Doesn't create a bin and tick value for all required categories (4, 5, 6, 8), instead creates a bin for non-existing value (10).&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=sashelp.cars; 
	where cylinders between 4 and 8; 
	table cylinders; 
run; 

proc sgplot data= sashelp.cars;
	where cylinders between 4 and 8; 
	histogram cylinders/nbins=4 binstart=4 showbins dataskin=pressed;
	yaxis label='Percent' ;
	xaxis label='Cylinder' ; 
run;  
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;2. Creates tick values for required categories (4, 5, 6, 8), but not creating a bin for category 5 with a centered tick value.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc sgplot data=sashelp.cars;
	where cylinders between 4 and 8; 
	histogram cylinders/nbins=4 binstart=4 showbins dataskin=pressed;
	yaxis label='Percent';
	xaxis label='Cylinder' values=(4 5 6 8) offsetmin=0.2 offsetmax=0.2; 
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;How to fix it in either way, that is to create 4 bins for categories 4, 5, 6, 8 and display tick values in the center of the bin?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Mar 2025 15:41:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-HISTOGRAM-Need-a-bin-for-each-category/m-p/963023#M25388</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2025-03-31T15:41:17Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT: HISTOGRAM. Need a bin for each category</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-HISTOGRAM-Need-a-bin-for-each-category/m-p/963025#M25389</link>
      <description>&lt;P&gt;Would a bar chart be sufficient for this case? Try this and see if you get what you want:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="sas"&gt;proc sgplot data=sashelp.cars;
	where cylinders between 4 and 8; 
	vbar cylinders / dataskin=pressed stat=pct;
	yaxis label='Percent';
	xaxis label='Cylinder'; 
run;&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 31 Mar 2025 16:03:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-HISTOGRAM-Need-a-bin-for-each-category/m-p/963025#M25389</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2025-03-31T16:03:28Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT: HISTOGRAM. Need a bin for each category</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-HISTOGRAM-Need-a-bin-for-each-category/m-p/963026#M25390</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15130"&gt;@DanH_sas&lt;/a&gt;,&amp;nbsp;&lt;BR /&gt;Thank you for the feedback!&lt;BR /&gt;This might be the very last option I could do if histograms not possible.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Mar 2025 16:08:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-HISTOGRAM-Need-a-bin-for-each-category/m-p/963026#M25390</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2025-03-31T16:08:29Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT: HISTOGRAM. Need a bin for each category</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-HISTOGRAM-Need-a-bin-for-each-category/m-p/963027#M25391</link>
      <description>&lt;P&gt;For your #1 example above, what do you get if you also set BINWIDTH=1?&lt;/P&gt;</description>
      <pubDate>Mon, 31 Mar 2025 16:15:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-HISTOGRAM-Need-a-bin-for-each-category/m-p/963027#M25391</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2025-03-31T16:15:30Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT: HISTOGRAM. Need a bin for each category</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-HISTOGRAM-Need-a-bin-for-each-category/m-p/963028#M25392</link>
      <description>&lt;P&gt;The same result with an additional NOTE:&lt;/P&gt;
&lt;PRE&gt;NOTE: The specified BINWIDTH= value will be ignored in order to accommodate the data
&lt;/PRE&gt;</description>
      <pubDate>Mon, 31 Mar 2025 16:18:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-HISTOGRAM-Need-a-bin-for-each-category/m-p/963028#M25392</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2025-03-31T16:18:00Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT: HISTOGRAM. Need a bin for each category</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-HISTOGRAM-Need-a-bin-for-each-category/m-p/963029#M25393</link>
      <description>&lt;P&gt;Try dropping the NBINS and see if the BINWIDTH is honored.&lt;/P&gt;</description>
      <pubDate>Mon, 31 Mar 2025 16:20:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-HISTOGRAM-Need-a-bin-for-each-category/m-p/963029#M25393</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2025-03-31T16:20:35Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT: HISTOGRAM. Need a bin for each category</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-HISTOGRAM-Need-a-bin-for-each-category/m-p/963071#M25394</link>
      <description>&lt;P&gt;I can not understand your question well .&lt;/P&gt;
&lt;P&gt;Can you post your desired output/graph ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And that is not a HISTOGRAM graph, it is just a VBAR graph as DanH_sas showed you .&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc freq data=sashelp.cars noprint; 
	where cylinders between 4 and 8; 
	table cylinders/out=temp; 
run; 
data temp;
 set temp;
 y=percent/2;
run;

proc sgplot data= temp noautolegend;
	vbarparm category=cylinders response=percent;
	text x=cylinders y=y text=cylinders/strip contributeoffset=none textattrs=(size=12);
	yaxis label='Percent' ;
	xaxis label='Cylinder' display=none; 
run;  &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Ksharp_0-1743471225548.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/105799i46EDDDD752B7E7C0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Ksharp_0-1743471225548.png" alt="Ksharp_0-1743471225548.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Apr 2025 01:33:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-HISTOGRAM-Need-a-bin-for-each-category/m-p/963071#M25394</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-04-01T01:33:55Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT: HISTOGRAM. Need a bin for each category</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-HISTOGRAM-Need-a-bin-for-each-category/m-p/963128#M25395</link>
      <description>&lt;P&gt;Yes, it does. However, now a new bin gets added for category 7.&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*Ex1;
proc sgplot data= sashelp.cars;
	where cylinders between 4 and 8; 
	histogram cylinders/binwidth=1 binstart=4 showbins dataskin=pressed;
	yaxis label='Percent' ;
	xaxis label='Cylinder' ; 
run;  &lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ex1.PNG" style="width: 707px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/105813i4D84D160B9A58474/image-size/large?v=v2&amp;amp;px=999" role="button" title="ex1.PNG" alt="ex1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Apr 2025 14:09:25 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-HISTOGRAM-Need-a-bin-for-each-category/m-p/963128#M25395</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2025-04-01T14:09:25Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT: HISTOGRAM. Need a bin for each category</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-HISTOGRAM-Need-a-bin-for-each-category/m-p/963133#M25396</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;BR /&gt;Thank you for the feedback. The result I need is almost the same as&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/15130"&gt;@DanH_sas&lt;/a&gt;&amp;nbsp;and you showed using VBAR/VBARPARAM statements, only without a space between bars. Just adding BARWIDTH=1 option eliminates the space and makes bars look like histogram. I was wondering if I can get the same result using&amp;nbsp; HISTOGRAM statement.&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;*Ex2;
proc sgplot data=sashelp.cars;
	where cylinders between 4 and 8; 
	vbar cylinders / barwidth=1 dataskin=pressed stat=pct;
	yaxis label='Percent';
	xaxis label='Cylinder'; 
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ex2.PNG" style="width: 704px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/105814i49124C91F25346E0/image-size/large?v=v2&amp;amp;px=999" role="button" title="ex2.PNG" alt="ex2.PNG" /&gt;&lt;/span&gt;&lt;CODE class=" language-sas"&gt;&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;out&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Apr 2025 14:23:17 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-HISTOGRAM-Need-a-bin-for-each-category/m-p/963133#M25396</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2025-04-01T14:23:17Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT: HISTOGRAM. Need a bin for each category</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-HISTOGRAM-Need-a-bin-for-each-category/m-p/963164#M25398</link>
      <description>I don't see any difference between VBAR and HISTOGRAM. Can you post a desired graph you need ?</description>
      <pubDate>Wed, 02 Apr 2025 01:00:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-HISTOGRAM-Need-a-bin-for-each-category/m-p/963164#M25398</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2025-04-02T01:00:23Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT: HISTOGRAM. Need a bin for each category</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-HISTOGRAM-Need-a-bin-for-each-category/m-p/963214#M25399</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;BR /&gt;Yes, you are right. Sorry for being unclear.&amp;nbsp;&lt;BR /&gt;My last post showed the desired graph using VBAR statement. &lt;BR /&gt;I wondered if the same result could be achieved with HISTOGRAM statement...&lt;/P&gt;</description>
      <pubDate>Wed, 02 Apr 2025 15:32:28 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-HISTOGRAM-Need-a-bin-for-each-category/m-p/963214#M25399</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2025-04-02T15:32:28Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT: HISTOGRAM. Need a bin for each category</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-HISTOGRAM-Need-a-bin-for-each-category/m-p/963219#M25400</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/321371"&gt;@A_Kh&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/18408"&gt;@Ksharp&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;BR /&gt;Yes, you are right. Sorry for being unclear.&amp;nbsp;&lt;BR /&gt;My last post showed the desired graph using VBAR statement. &lt;BR /&gt;I wondered if the same result could be achieved with HISTOGRAM statement...&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;I doubt it since the graph you want isn't actually a histogram.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Apr 2025 15:51:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-HISTOGRAM-Need-a-bin-for-each-category/m-p/963219#M25400</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-04-02T15:51:06Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT: HISTOGRAM. Need a bin for each category</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-HISTOGRAM-Need-a-bin-for-each-category/m-p/963221#M25401</link>
      <description>&lt;P&gt;Looks like I need to go with Bar chart when visualizing categorical data. As data are mostly continuous variables, the requirement was histogram graphs. I don't really see the difference between my last graph(bar chart without a gap between bars) and histogram. As you said this is not a histogram then there should be some differences. Please let me know if there is a visual distinction between the last graph&amp;nbsp; and a histogram, except the type of data they should use.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Apr 2025 16:39:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-HISTOGRAM-Need-a-bin-for-each-category/m-p/963221#M25401</guid>
      <dc:creator>A_Kh</dc:creator>
      <dc:date>2025-04-02T16:39:14Z</dc:date>
    </item>
    <item>
      <title>Re: PROC SGPLOT: HISTOGRAM. Need a bin for each category</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-HISTOGRAM-Need-a-bin-for-each-category/m-p/963252#M25402</link>
      <description>&lt;P&gt;Oxford Dictionary definition of histogram.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Tom_0-1743623494677.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/105851i724D747EB4B2849A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Tom_0-1743623494677.png" alt="Tom_0-1743623494677.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Your graph using the HISTOGRAM statement had a zero height bar for the interval centered on 7 because the frequency of that class interval was zero.&lt;/P&gt;</description>
      <pubDate>Wed, 02 Apr 2025 19:53:33 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/PROC-SGPLOT-HISTOGRAM-Need-a-bin-for-each-category/m-p/963252#M25402</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2025-04-02T19:53:33Z</dc:date>
    </item>
  </channel>
</rss>

