Hello,
Please help with the following: How to dynamically change the axis range of Bar-Line graph in EG.
I have a dataset consists of X number of schools and the numbers of Students and Tardy per month. I want to use Bar-Line chart to show the number of Students as bar and the number of Tardy as line for each month, per each school. And for each school I want to dynamically change the axis ranges (and the tick-mark) based on the highest number of Student and the highest number of Tardy so that each school's graph is tailored to its own population. Here is my dataset:
School FileDate Student Tardy
School_A 01/31/2018 74 7
School_A 02/28/2018 77 8
School_A 03/31/2018 70 2
School_A 04/30/2018 72 1
School_A 05/31/2018 73 2
School_A 06/30/2018 79
School_B 01/31/2018 381 3
School_B 02/28/2018 401 10
School_B 03/31/2018 396 7
School_B 04/30/2018 413 6
School_B 05/31/2018 404 12
School_B 06/30/2018 401 7
School_C 01/31/2018 72 4
School_C 02/28/2018 64 2
School_C 03/31/2018 63
School_C 04/30/2018 75 2
School_C 05/31/2018 75 3
School_C 06/30/2018 81 1
School_D 01/31/2018 446 12
School_D 02/28/2018 437 3
School_D 03/31/2018 460 5
School_D 04/30/2018 467 6
School_D 05/31/2018 467 8
School_D 06/30/2018 472 2
Here is my codes. I think the Axis1 and Axis3 are the one I need to make the changes but so far I haven't got it work out yet. Please help. Thank you
PROC GBARLINE DATA=WORK.SchoolCount;
title1 "Number of Student versus Tardiness";
Axis1
STYLE=1
WIDTH=1
ORDER=(0 TO 500 BY 100)
MINOR=NONE
LABEL=( FONT='/b' ANGLE=90 "Number of Student");
Axis2
STYLE=1
WIDTH=1
VALUE=(ANGLE=45)
LABEL=NONE;
Axis3
STYLE=1
WIDTH=1
ORDER=(0 TO 20 BY 5)
MINOR=NONE
LABEL=( FONT='/b' ANGLE=90 "Number of Tardy") ;
BAR FileDate/
SUMVAR=Student
CLIPREF
SPACE=10
FRAME DISCRETE
TYPE=SUM
COUTLINE=SAME
RAXIS=AXIS1
MAXIS=AXIS2
LEGEND=LEGEND2;
PLOT / SUMVAR=Tardy
TYPE=SUM
CLIPREF
AXIS=AXIS3
LEGEND=LEGEND1
LREF=1
CREF=BLACK
AUTOREF;
FORMAT FileDate MONYY6.;
BY School;
FORMAT FileDate MONYY6.;
RUN; QUIT;
Easiest to make that dynamic would be to remove the ORDER clause in the Axis statements.
You might have ticks that you don't quite want but the range will adjust based on the data.
hi Ballardw,
Thank you for your suggestion.
Save $250 on SAS Innovate and get a free advance copy of the new SAS For Dummies book! Use the code "SASforDummies" to register. Don't miss out, May 6-9, in Orlando, Florida.
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.