<?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 group vbar using sgplot? in Graphics Programming</title>
    <link>https://communities.sas.com/t5/Graphics-Programming/How-to-group-vbar-using-sgplot/m-p/68927#M2409</link>
    <description>You seem to have 3 separate columns.  With this data structure, you have a couple of options.   With SAS (TS2M3), you can get the bars side by side using GTL.  Else, you can get overlaid bars.  See code below.  The DISCRETEOFFSET option in GTL will not work for a SAS release prior to TS2M3.&lt;BR /&gt;
&lt;BR /&gt;
Side-by-side grouped bar charts are coming with SAS 9.3.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data subset;&lt;BR /&gt;
  input month $ sales_a sales_b sales_acum;&lt;BR /&gt;
  datalines;&lt;BR /&gt;
Jan  200  300  500&lt;BR /&gt;
Feb  300  400  700&lt;BR /&gt;
Mar  200  400  600&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
proc print;run;&lt;BR /&gt;
&lt;BR /&gt;
/*--SGPLOT--*/&lt;BR /&gt;
ods graphics / width=4in height=3in imagename='BarsSG';&lt;BR /&gt;
proc sgplot data=work.subset;  &lt;BR /&gt;
   title "Budget and Sales";&lt;BR /&gt;
   vbar month/  response=sales_A nostatlabel;     &lt;BR /&gt;
   vbar month/ response=sales_B  barwidth=0.6 nostatlabel;      &lt;BR /&gt;
   vline month/ response=sales_acum y2axis lineattrs=(pattern=solid thickness=4) nostatlabel;&lt;BR /&gt;
   yaxis offsetmin=0;&lt;BR /&gt;
   xaxis discreteorder=data;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
/*--GTL--*/&lt;BR /&gt;
proc template;&lt;BR /&gt;
  define statgraph bars;&lt;BR /&gt;
    begingraph;&lt;BR /&gt;
	  entrytitle "Budget and Sales";&lt;BR /&gt;
      layout overlay / yaxisopts=(offsetmin=0);&lt;BR /&gt;
	    barchart x=month y=sales_a / discreteoffset=-0.2 barwidth=0.4 fillattrs=graphdata1 name='a';&lt;BR /&gt;
		barchart x=month y=sales_b / discreteoffset= 0.2 barwidth=0.4 fillattrs=graphdata2 name='b';&lt;BR /&gt;
		seriesplot x=month y=sales_acum / lineattrs=graphdata3(pattern=solid thickness=4) yaxis=y2 name='c';&lt;BR /&gt;
		discretelegend 'a' 'b' 'c';&lt;BR /&gt;
	  endlayout;&lt;BR /&gt;
	endgraph;&lt;BR /&gt;
  end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
ods graphics / width=4in height=3in imagename='BarsGTL';&lt;BR /&gt;
proc sgrender data=work.subset template=bars; &lt;BR /&gt;
  run;</description>
    <pubDate>Tue, 24 May 2011 16:41:50 GMT</pubDate>
    <dc:creator>Jay54</dc:creator>
    <dc:date>2011-05-24T16:41:50Z</dc:date>
    <item>
      <title>How to group vbar using sgplot?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-group-vbar-using-sgplot/m-p/68925#M2407</link>
      <description>Hi! I need you help! I'm trying to use the proc sgplot in order to plot 3 variables: 1 with a line, and the other 2 variable with grouped vertical bars (no stacked).  I've tried several ways but i can´t get what I need... this is my code:&lt;BR /&gt;
&lt;BR /&gt;
proc sgplot data=work.subset;  &lt;BR /&gt;
   title "Budget and sales";&lt;BR /&gt;
   vbar month/  response=sales_A ;     &lt;BR /&gt;
   vbar month/ response=sales_B;      &lt;BR /&gt;
   vline month/ response=sales_acum y2axis;&lt;BR /&gt;
&lt;BR /&gt;
run;</description>
      <pubDate>Tue, 24 May 2011 14:17:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-group-vbar-using-sgplot/m-p/68925#M2407</guid>
      <dc:creator>Ture</dc:creator>
      <dc:date>2011-05-24T14:17:11Z</dc:date>
    </item>
    <item>
      <title>Re: How to group vbar using sgplot?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-group-vbar-using-sgplot/m-p/68926#M2408</link>
      <description>Can you post the code for your data set?</description>
      <pubDate>Tue, 24 May 2011 16:22:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-group-vbar-using-sgplot/m-p/68926#M2408</guid>
      <dc:creator>Jay54</dc:creator>
      <dc:date>2011-05-24T16:22:41Z</dc:date>
    </item>
    <item>
      <title>Re: How to group vbar using sgplot?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-group-vbar-using-sgplot/m-p/68927#M2409</link>
      <description>You seem to have 3 separate columns.  With this data structure, you have a couple of options.   With SAS (TS2M3), you can get the bars side by side using GTL.  Else, you can get overlaid bars.  See code below.  The DISCRETEOFFSET option in GTL will not work for a SAS release prior to TS2M3.&lt;BR /&gt;
&lt;BR /&gt;
Side-by-side grouped bar charts are coming with SAS 9.3.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
data subset;&lt;BR /&gt;
  input month $ sales_a sales_b sales_acum;&lt;BR /&gt;
  datalines;&lt;BR /&gt;
Jan  200  300  500&lt;BR /&gt;
Feb  300  400  700&lt;BR /&gt;
Mar  200  400  600&lt;BR /&gt;
;&lt;BR /&gt;
run;&lt;BR /&gt;
proc print;run;&lt;BR /&gt;
&lt;BR /&gt;
/*--SGPLOT--*/&lt;BR /&gt;
ods graphics / width=4in height=3in imagename='BarsSG';&lt;BR /&gt;
proc sgplot data=work.subset;  &lt;BR /&gt;
   title "Budget and Sales";&lt;BR /&gt;
   vbar month/  response=sales_A nostatlabel;     &lt;BR /&gt;
   vbar month/ response=sales_B  barwidth=0.6 nostatlabel;      &lt;BR /&gt;
   vline month/ response=sales_acum y2axis lineattrs=(pattern=solid thickness=4) nostatlabel;&lt;BR /&gt;
   yaxis offsetmin=0;&lt;BR /&gt;
   xaxis discreteorder=data;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
/*--GTL--*/&lt;BR /&gt;
proc template;&lt;BR /&gt;
  define statgraph bars;&lt;BR /&gt;
    begingraph;&lt;BR /&gt;
	  entrytitle "Budget and Sales";&lt;BR /&gt;
      layout overlay / yaxisopts=(offsetmin=0);&lt;BR /&gt;
	    barchart x=month y=sales_a / discreteoffset=-0.2 barwidth=0.4 fillattrs=graphdata1 name='a';&lt;BR /&gt;
		barchart x=month y=sales_b / discreteoffset= 0.2 barwidth=0.4 fillattrs=graphdata2 name='b';&lt;BR /&gt;
		seriesplot x=month y=sales_acum / lineattrs=graphdata3(pattern=solid thickness=4) yaxis=y2 name='c';&lt;BR /&gt;
		discretelegend 'a' 'b' 'c';&lt;BR /&gt;
	  endlayout;&lt;BR /&gt;
	endgraph;&lt;BR /&gt;
  end;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
ods graphics / width=4in height=3in imagename='BarsGTL';&lt;BR /&gt;
proc sgrender data=work.subset template=bars; &lt;BR /&gt;
  run;</description>
      <pubDate>Tue, 24 May 2011 16:41:50 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-group-vbar-using-sgplot/m-p/68927#M2409</guid>
      <dc:creator>Jay54</dc:creator>
      <dc:date>2011-05-24T16:41:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to group vbar using sgplot?</title>
      <link>https://communities.sas.com/t5/Graphics-Programming/How-to-group-vbar-using-sgplot/m-p/68928#M2410</link>
      <description>Thanks for your example! it was quite helpful. I've tried  both options and the second is the best. Regards!</description>
      <pubDate>Fri, 03 Jun 2011 18:29:46 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Graphics-Programming/How-to-group-vbar-using-sgplot/m-p/68928#M2410</guid>
      <dc:creator>Ture</dc:creator>
      <dc:date>2011-06-03T18:29:46Z</dc:date>
    </item>
  </channel>
</rss>

