Help using Base SAS procedures

side by side grouped bar graph

Reply
New Contributor
Posts: 2

side by side grouped bar graph

I am having trouble making a side by side verticle bar graph and I am wondering if my data are sorted poorly.

My data  are in the attached files which have not been working out.

I would like the figure to look like the attachment titled "capture"


Capture.JPG
Attachment
SAS Super FREQ
Posts: 8,868

Re: side by side grouped bar graph

Hi:

  What code are you using? SAS/GRAPH and PROC GCHART or ODS GRAPHICS and PROC SGPLOT or???

    What is your destination of interest? HTML, RTF, PDF?

cynthia

New Contributor
Posts: 2

Re: side by side grouped bar graph

Posted in reply to Cynthia_sas

The code I have been using with no luck is very similar to sanjay's response.

data y72 y13; set nototals

year=72; totalseed=Dc1_1972; output y72;

year13; totalseed=Dc1_2013, ouput y13;

run;

proc sgplot;

vbar year / group=year groupdisplay=cluster response=totalseed;

run;

this just gets the one group (Dc1) garphed when I want DC1, DC2 and DC3 all on the same graph

S

SAS Super FREQ
Posts: 1,171

Re: side by side grouped bar graph

First - You are using the same variable (year) for both category and group. There is no distinct GROUP variable.  Second, the graph will depend on your data.  You need a column with DC1, DC2, etc. as values in the column, and this column should be provided as the GROUP role in the statement.

SAS Super FREQ
Posts: 1,171

Re: side by side grouped bar graph

A smaller sample data with just what you need would be easier to work with.  If you have SAS 9.3 or higher, you can use the following SGPLOT example.  Substitute the appropriate data set, category, group and response variables.  "Cluster" is a keyword you must use.   

proc sgplot data=sashelp.cars;

vbar origin/ response=mpg_city group=type groupdisplay=cluster;

run;

Ask a Question
Discussion stats
  • 4 replies
  • 241 views
  • 0 likes
  • 3 in conversation