04-17-2016 11:38 AM - edited 04-17-2016 11:40 AM
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).
04-18-2016 05:42 AM - edited 04-18-2016 05:44 AM
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;
04-18-2016 09:41 AM
@Bruno_SAS 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
04-18-2016 10:01 AM - edited 04-18-2016 12:05 PM
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 @Sanjay_SAS 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 @RobertAllison_SAS 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.