I have attached input dataset sample that has values for the bar chart and I have also attached the wanted barchart sample.
In the bar chart , I need find out from 2007 to 2010, how many times(frequency) GY1, GY2 and GY3 are ranked in each year (shown as numbers under bars on the graph attached). And within each year’s bars I’d also like to know what the proportions are respectively that GY1, GY2 and GY3 are ranked as 1st, 2nd and 3rd (shown as percentages within each bars).
Please consider adding data and image directly to your post. Not everyone can download attachments.
Hi
Not exactly the graph your are looking for, but it is a start, and it has all the information you are looking for. I have used Proc SGPANEL instead of Proc GCHART.
data have;
infile cards dlm=",";
input
Year
Ranking
Group_Y_Name $
cnt_gy_name
;
cards;
2007,1,GY1,2
2007,2,GY1,1
2007,1,GY2,2
2007,2,GY2,2
2007,1,GY3,1
2007,2,GY3,1
2007,3,GY3,1
2008,1,GY1,1
2008,2,GY1,1
2008,3,GY1,1
2008,1,GY2,1
2008,2,GY2,2
2008,1,GY3,1
2008,3,GY3,1
2009,2,GY1,3
2009,3,GY1,1
2009,1,GY2,4
2009,1,GY3,1
2009,2,GY3,1
2009,3,GY3,1
2010,1,GY1,2
2010,2,GY1,2
2010,1,GY2,4
2010,2,GY2,1
2010,1,GY3,1
2010,2,GY3,3
;
proc sgpanel data=have pctlevel=group;
styleattrs
datacolors=(cxfddcbb cxaddfe6 cxf5f8c9)
datacontrastcolors=(cxfddcbb cxaddfe6 cxf5f8c9)
;
panelby Group_Y_Name /
layout=columnlattice
colheaderpos=bottom
novarname
noborder
;
vbar year /
response=cnt_gy_name
group=Ranking stat=percent
seglabel seglabelformat=percent9.
;
colaxistable cnt_gy_name;
keylegend / noborder TITLE=" ";
run;
Bruno
@BrunoMueller Very nice Sir, Thank you so much. That pretty much did it for me. It seems like you have loads of experience in SAS. How did you manage to read, understand and remember all these options. Is there a method or technique to learn SAS more effectively? I would welcome your suggestions plz
Allaluiah
If you are new to SAS, it is worthwhile to attend a SAS Training course, to get all the fundamental concepts right. This makes reading the code examples you will find everywhere a lot easier.
For all things related to ODS Graphics I suggest you follow the blog http://blogs.sas.com/content/graphicallyspeaking/ by @Jay54 it has lots and lots of great examples and tips and tricks on how to best use ODS Graphics.
For SAS/GRAPH read the blogs entries from @GraphGuy http://blogs.sas.com/content/sastraining/author/robertallison/ one can only wonder what is possible.
The thing is, one has to remember. But since there is always a story around it, this makes it a lot easier, at least for me.
Bruno
See a gchart solution in rakul's thread. Are you two working together, or just happen to be wanting the same graph?
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.