<?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: How to create nested bars within a bar in base SAS? in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/How-to-create-nested-bars-within-a-bar-in-base-SAS/m-p/814739#M22847</link>
    <description>&lt;P&gt;Given the code you have, the best two options to fix your outlines are one of the following:&lt;/P&gt;
&lt;P&gt;1. Duplicate the DATACOLORS colors in the DATACONTRASTCOLORS option. This will override the style line colors and set them to be the same as the fill colors.&lt;/P&gt;
&lt;P&gt;2. Use OUTLINEATTRS=(color=black) on the VBARBASIC statement to set all of the outline colors to black. I think this is the better option to help the interior bars to stand out from the large bar.&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;</description>
    <pubDate>Mon, 23 May 2022 17:18:54 GMT</pubDate>
    <dc:creator>DanH_sas</dc:creator>
    <dc:date>2022-05-23T17:18:54Z</dc:date>
    <item>
      <title>How to create nested bars within a bar in base SAS?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-create-nested-bars-within-a-bar-in-base-SAS/m-p/814365#M22836</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I would be grateful if anyone could show how to create the nested bar within a bar graph looks like below in base SAS 9.4 M7.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The input SAS data set can be used here &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;data retail; set sashelp.retail;&lt;BR /&gt;run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Ethan&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="t75wez1_0-1652991761689.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/71645i1AF4F42252810474/image-size/medium?v=v2&amp;amp;px=400" role="button" title="t75wez1_0-1652991761689.png" alt="t75wez1_0-1652991761689.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 May 2022 20:35:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-create-nested-bars-within-a-bar-in-base-SAS/m-p/814365#M22836</guid>
      <dc:creator>t75wez1</dc:creator>
      <dc:date>2022-05-19T20:35:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to create nested bars within a bar in base SAS?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-create-nested-bars-within-a-bar-in-base-SAS/m-p/814373#M22837</link>
      <description>&lt;P&gt;This is one basic approach:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;
proc sgplot data=sashelp.retail;
   where year &amp;lt; 1985; 
   vbarbasic year/ response=sales barwidth=1 fillattrs=(color=verylightblue)
      datalabel
   ;
   vbarbasic year/ response= sales group= date groupdisplay=cluster clusterwidth=1
      datalabel;
   format date qtr.;
   label date= 'Quarter';
run;&lt;/PRE&gt;
&lt;P&gt;Note the BARWIDTH for the non-grouped data and the CLUSTERWIDTH for the grouped data. These are ratios of the total space and I think from your example you want the values the same though if you use less than 1 there will be space between the years.&lt;/P&gt;
&lt;P&gt;The VBARBASIC version is needed instead of VBAR to allow different group options between the plot statements.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 May 2022 20:55:30 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-create-nested-bars-within-a-bar-in-base-SAS/m-p/814373#M22837</guid>
      <dc:creator>ballardw</dc:creator>
      <dc:date>2022-05-19T20:55:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to create nested bars within a bar in base SAS?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-create-nested-bars-within-a-bar-in-base-SAS/m-p/814375#M22838</link>
      <description>&lt;P&gt;Hi:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Did you do any other manipulations on SASHELP.RETAIL? The reason I ask is that I only see 58 total rows in the file, so I wonder what constitutes an event for the Y axis:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_1-1652993517053.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/71647i9AF92E54D2984DE7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_1-1652993517053.png" alt="Cynthia_sas_1-1652993517053.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;In addition, regarding your YEAR value, when I do a PROC FREQ on YEAR, I only see values from 1980-1994, as shown below:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_2-1652993590918.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/71648i5E0EBCD4C8ABCA4F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_2-1652993590918.png" alt="Cynthia_sas_2-1652993590918.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;So I wonder where the dates in your example came from.&lt;/P&gt;
&lt;P&gt;A partial PROC PRINT shows the data to be like this:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Cynthia_sas_3-1652993710377.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/71649i34CFE2D408BCE414/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Cynthia_sas_3-1652993710377.png" alt="Cynthia_sas_3-1652993710377.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Note that DATE is formatted with the YYQ4 format.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; I'm just curious what code you tried or if you used sashelp.retail for your example of desired output.&lt;/P&gt;
&lt;P&gt;Cynthia&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 May 2022 20:56:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-create-nested-bars-within-a-bar-in-base-SAS/m-p/814375#M22838</guid>
      <dc:creator>Cynthia_sas</dc:creator>
      <dc:date>2022-05-19T20:56:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to create nested bars within a bar in base SAS?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-create-nested-bars-within-a-bar-in-base-SAS/m-p/814470#M22842</link>
      <description>&lt;P&gt;Cynthia,&lt;/P&gt;&lt;P&gt;Thanks for the response.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The input SAS data set named "SASHELP.RETAIL" is not same as the data set used for building the graph in SAS Viya from the link below.&lt;/P&gt;&lt;P&gt;&lt;A href="https://communities.sas.com/t5/Graphics-Programming/How-to-create-nested-bars-within-a-bar-in-base-SAS/m-p/814365#M22836" target="_blank"&gt;https://communities.sas.com/t5/Graphics-Programming/How-to-create-nested-bars-within-a-bar-in-base-SAS/m-p/814365#M22836&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 May 2022 16:06:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-create-nested-bars-within-a-bar-in-base-SAS/m-p/814470#M22842</guid>
      <dc:creator>t75wez1</dc:creator>
      <dc:date>2022-05-20T16:06:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to create nested bars within a bar in base SAS?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-create-nested-bars-within-a-bar-in-base-SAS/m-p/814494#M22843</link>
      <description>&lt;P&gt;&lt;FONT size="2"&gt;Thanks so much&amp;nbsp; for your help.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;Below is my code based on your suggestion. It's not perfect. For instance, the edge of colors on nested bars doesn't match the colors of bars ifself. Also don't know how to customized legend to match the the example of graph.&amp;nbsp;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;I'm appreciative of any help you may provide.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT size="2"&gt;&lt;SPAN class=""&gt;Ethan&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;%let name=Nested_bars;
filename odsout '.';
ODS LISTING CLOSE;
ODS HTML path=odsout body="&amp;amp;name..htm" 
 (title="&amp;amp;name.") 
 style=htmlblue;
ods graphics /
 noscale /* if you don't use this option, the text will be resized */
 imagemap tipmax=2500 
 imagefmt=png imagename="&amp;amp;name"
 width=800px height=600px noborder; 

title1 h=13pt color=purple "Retail Sales";
proc sgplot data=sashelp.retail noborder;
   where year &amp;lt; 1985; 
   styleattrs backcolor=white wallcolor=white datacolors=(cxe6eef7  cxc7e3ff cx89cbf2 cx1d94da cx377eb8 );
   vbarbasic year/ response=sales barwidth=0.95 fillattrs=(color=aliceblue) transparency=0.4
      datalabel DATALABELATTRS=(Color=grey55 Family="Arial" Size=8 
        Style=normal Weight=Bold)
   ;
   vbarbasic year/ response= sales group= date BARWIDTH=0.85 transparency=0.4 groupdisplay=cluster clusterwidth=0.97
      datalabel DATALABELATTRS=(Color=black Family="Arial" Size=6 
        Style=normal Weight=Bold);
	xaxis display=(noline  nolabel)

 valueattrs=(color=black size=8.0pt Weight=Bold)
 
 ;
 
		yaxis display=(noline noticks)

 labelattrs=(color=gray33 size=8pt Weight=Bold)
 labelpos=top
 values=(0 to 1600 by 400)
 valueattrs=(color=gray33 size=8pt Weight=Bold)
 
 offsetmin=0 offsetmax=0 ;
 refline  400  800 1200 1600 /axis=y lineattrs=(color=lightgray thickness=1.2 pattern=shortDash);
    *keylegend /   noborder position=bottom ;
   format date qtr.;
   label date= 'Quarter' ;
run;
quit;
ODS HTML CLOSE;
ODS LISTING;&lt;/CODE&gt;&amp;nbsp;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 May 2022 21:58:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-create-nested-bars-within-a-bar-in-base-SAS/m-p/814494#M22843</guid>
      <dc:creator>t75wez1</dc:creator>
      <dc:date>2022-05-20T21:58:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to create nested bars within a bar in base SAS?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-create-nested-bars-within-a-bar-in-base-SAS/m-p/814659#M22846</link>
      <description>&lt;P&gt;Here is the result.&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Nested_bars5.png" style="width: 800px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/71705i7A1E281AD09BF27E/image-size/large?v=v2&amp;amp;px=999" role="button" title="Nested_bars5.png" alt="Nested_bars5.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 23 May 2022 03:57:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-create-nested-bars-within-a-bar-in-base-SAS/m-p/814659#M22846</guid>
      <dc:creator>t75wez1</dc:creator>
      <dc:date>2022-05-23T03:57:55Z</dc:date>
    </item>
    <item>
      <title>Re: How to create nested bars within a bar in base SAS?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-create-nested-bars-within-a-bar-in-base-SAS/m-p/814739#M22847</link>
      <description>&lt;P&gt;Given the code you have, the best two options to fix your outlines are one of the following:&lt;/P&gt;
&lt;P&gt;1. Duplicate the DATACOLORS colors in the DATACONTRASTCOLORS option. This will override the style line colors and set them to be the same as the fill colors.&lt;/P&gt;
&lt;P&gt;2. Use OUTLINEATTRS=(color=black) on the VBARBASIC statement to set all of the outline colors to black. I think this is the better option to help the interior bars to stand out from the large bar.&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;</description>
      <pubDate>Mon, 23 May 2022 17:18:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-create-nested-bars-within-a-bar-in-base-SAS/m-p/814739#M22847</guid>
      <dc:creator>DanH_sas</dc:creator>
      <dc:date>2022-05-23T17:18:54Z</dc:date>
    </item>
    <item>
      <title>Re: How to create nested bars within a bar in base SAS?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-create-nested-bars-within-a-bar-in-base-SAS/m-p/814809#M22849</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Thank you so much again for all your help&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13633" target="_blank"&gt;@DanH_sas.&amp;nbsp;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I obtained the desired result based on your the 2nd suggestion.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ethan&lt;/P&gt;</description>
      <pubDate>Tue, 24 May 2022 00:37:29 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-create-nested-bars-within-a-bar-in-base-SAS/m-p/814809#M22849</guid>
      <dc:creator>t75wez1</dc:creator>
      <dc:date>2022-05-24T00:37:29Z</dc:date>
    </item>
  </channel>
</rss>

