gbarline bars

Reply
Contributor
Posts: 42

gbarline bars


Hello All,

Using gbarline procedure, can I group the bars or give give color to a group of bars?

I couldn't get any option to group the bars(say by year)... so thought of coloring the bars by year using the PATTERNID option. But patternid requires the use of BY statement.

By using BY statement i can color & group them but then a separate graph gets created for each value of BY variable which I dont want...

proc gbarline data=temp;

bar date1 / discrete sumvar=y1v patternid=by;

plot / sumvar=y2v axis=axis2;

by year;

run;

quit;

Can somebody pls let me know if its possible to group bars using gbarline?

Super Contributor
Posts: 543

Re: gbarline bars

You could use a subgroup = your_variable for the bar plot.; but first you need to sort your data by that group variable.

Here is an example using the SASHELP.CLASS data set.

proc sort data= sashelp.class out = temp;by sex;

proc gbarline data = temp;

bar name / discrete sumvar = age subgroup = sex;

plot / sumvar = weight ;

run;

quit;

Best of luck.

Anca.

Contributor
Posts: 42

Re: gbarline bars

Posted in reply to AncaTilea


Thanks Anca, this works ...that is I get different colors for different groups....    Smiley Happy

I had seen subgroup option creating stacked bars...so thought it wont be used to create grouped bars/or color them..  Thanks once again,Anca!!

Also , if I want to display only the subgroup values below the X-axis or M-axis then is that possible...

Like suppose, each bar represents  a month ... Jan, feb, mar....

But i dont want to display month or monYY   below each bar....   I only want to display year 2001 , 2002  below a set/group of bars for a particular year....??

DATE1Y1VY2VYEAR
1-Jan-08100122008
1-Feb-08100232008
1-Mar-08100342008
1-Apr-08100452008
1-May-08100562008
1-Jun-08100672008
1-Jul-08100782008
1-Aug-08100892008
1-Sep-081009102008
1-Oct-081010112008
1-Nov-081011122008
1-Dec-081012132008
1-Jan-091013142009
1-Feb-091014152009
1-Mar-091015162009
1-Apr-091016172009
1-May-091017182009
1-Jun-091018192009
1-Jul-091019202009
1-Aug-091020212009
1-Sep-091021222009
1-Oct-091022232009
1-Nov-091023242009
1-Dec-091024252009
1-Jan-101025262010
1-Feb-101026272010
1-Mar-101027282010
1-Apr-101028292010
1-May-101029302010
1-Jun-101030312010
1-Jul-101031322010
1-Aug-101032332010
1-Sep-101033342010
1-Oct-101034352010
1-Nov-101035362010
1-Dec-101036372010

proc gbarline data=temp;

   bar date1 / discrete sumvar=y1v subgroup=year;

   plot / sumvar=y2v axis=axis2;

   run;

quit;

Super Contributor
Posts: 543

Re: gbarline bars

Sure, you could display only the value for the subgroup.

One dirty way to do that (given that you have exactly 12 months of data in each year) would be to assign blank values to the tick marks, and the 2008, 2009 or 2010 value for some of the tick marks.

See below:

goptions reset = all;

axis1 v = ("" "" "" "" "" "2008" "" "" "" "" "" ""

            "" "" "" "" "" "2009" "" "" "" "" "" ""

            "" "" "" "" "" "2010" "" "" "" "" "" "");

proc gbarline data=temp;

   bar date1 / discrete sumvar=y1v subgroup=year maxis = axis1;

   plot / sumvar=y2v;

run;quit;

Contributor
Posts: 42

Re: gbarline bars

Posted in reply to AncaTilea

Thanks Anca.... This is also helpful

Ask a Question
Discussion stats
  • 4 replies
  • 342 views
  • 0 likes
  • 2 in conversation