07-03-2013 10:54 PM
I was wondering if there is a possibility for PROC GBARLINE to plot 3 charts in single primary axis and 3 lines in single secondary axis. Basically my data set contains variables such as average student final exam in semester 1,2,3 and average number of hours student study in semester 1,2,3. Herein my data set example :
Class exam_1 exam_2 exam_3 studyhours_1 studyhours_2 studyhours_3
Math 6.2 7.5 7.0 4 4 5
Physic 7.12 6.7 5.8 5 3 4
Is there a way for PROC GBARLINE to manage all of these data in single picture ?
Thanks for any help!.
07-04-2013 01:22 PM
I will let other GRAPH experts answer the GBARLINE question. With SAS 9.3, you can certainly do this using proc SGPLOT. While data is reorganized as group (for convenience), you can certainly also use the multi column format, with different syntax. Having same number of ticks on both Y & Y2 axis allows using grids lines.
input Subject $1-8 Semester Score StudyTime;
Math 1 6.2 4
Math 2 7.5 4
Math 3 7.0 5
Physics 1 7.12 5
Physics 2 6.7 3
Physics 3 5.8 4
ods listing style=htmlblue gpath=&gpath;
ods graphics / reset width=4in height=3in imagename='BarLine3';
proc sgplot data=scores;
title 'Scores and Study Time by Subject and Semester';
vbar subject / response=score group=semester groupdisplay=cluster
nostatlabel dataskin=gloss name='a';
vline subject / response=studytime group=semester nostatlabel y2axis lineattrs=(thickness=5);
yaxis min=0 offsetmin=0 values=(0 to 10 by 2) grid label='Score (Bar)';
y2axis min=0 offsetmin=0 label='Study Time in Hours (Line)';
keylegend 'a' / title='Semester';
Switching Group and Category gives an alternate arrangement, recommended by some when using Line Charts:
07-04-2013 11:05 PM
Please see first line of my code (%let).
For more information see Graphically Speaking blog.