Hi. I would like to change the X-axis to 0-24 as well as the legend from '1' to 'January' etc.
Here's my code:
proc sort data = matt; by Month Hour; run; proc summary data = matt; by Month Hour; var Load; output out = means (drop = _:) mean = mean n = n stderr = stderr; run; symbol1 i = j value = W font = marker c = vivb h = 1 line = 1 width = 1; symbol2 i = j value = W font = marker c = bigb h = 1 line = 1 width = 1; symbol3 i = j value = W font = marker c = liolbr h = 1 line = 1 width = 1; symbol4 i = j value = W font = marker c = lilg h = 1 line = 1 width = 1; symbol5 i = j value = W font = marker c = vilg h = 1 line = 1 width = 1; symbol6 i = j value = W font = marker c = salmon h = 1 line = 1 width = 1; symbol7 i = j value = W font = marker c = vipk h = 1 line = 1 width = 1; symbol8 i = j value = W font = marker c = lippk h = 1 line = 1 width = 1; symbol9 i = j value = W font = marker c = strbr h = 1 line = 1 width = 1; symbol10 i = j value = W font = marker c = morbr h = 1 line = 1 width = 1; symbol11 i = j value = W font = marker c = debr h = 1 line = 1 width = 1; symbol12 i = j value = W font = marker c = bib h = 1 line = 1 width = 1; proc gplot data = means; plot mean * Hour = Month; format Month; run;
and here's how it looks now:
if you must use Proc Gplot then the appearance of Axis values is controlled by an Axis statement.
To select values use an ORDER= option.
Axis1 order= (1 to 24 by 1);
the "by" values can be date or time intervals for date, time or datetime values when you have those.
You can have up to 99 axis statements active at one time similar to symbol statements, so use 1 to 99 to indicate which statement is used.
Then in the procedure you associate an axis definition with the role such as haxis=axis1 as an option to the plot statement where you want it to apply:
proc gplot data = means;
plot mean * Hour = Month / haxis=axis1;
format Month <your format name goes here>.;
run;
Your not applying any format to month with:
format Month;
Maybe:
format Month monname.;
As for changing an axis, afraid I haven't used gplot in years. I would advise to move to sgplot and gtl, far more advanced, and customisable. Check here for examples:
if you must use Proc Gplot then the appearance of Axis values is controlled by an Axis statement.
To select values use an ORDER= option.
Axis1 order= (1 to 24 by 1);
the "by" values can be date or time intervals for date, time or datetime values when you have those.
You can have up to 99 axis statements active at one time similar to symbol statements, so use 1 to 99 to indicate which statement is used.
Then in the procedure you associate an axis definition with the role such as haxis=axis1 as an option to the plot statement where you want it to apply:
proc gplot data = means;
plot mean * Hour = Month / haxis=axis1;
format Month <your format name goes here>.;
run;
I think this is what you're looking for:
data means;
input Month Hour Mean;
datalines;
1 1 5
1 2 4
1 3 3.5
1 4 4
1 5 5
1 6 6
1 7 7
1 8 8
1 9 9
1 10 10
1 11 11
1 12 12
1 13 13
1 14 14
1 15 14.5
1 16 14
1 17 13
1 18 12
1 19 11
1 20 10.5
1 21 11
1 22 12
1 23 13
1 24 14
;
run;
axis1 order=(0 to 20 by 5) minor=none offset=(0,0);
axis2 order=(0 to 24 by 6) minor=none offset=(0,0);
legend1 repeat=2 value=(justify=left);
proc format;
value monfmt
1='Jan'
2='Feb'
3='Mar'
4='Apr'
5='May'
6='Jun'
7='Jul'
8='Aug'
9='Sep'
10='Oct'
11='Nov'
12='Dec'
;
run;
symbol1 i=join value=W font=marker c=red h=1 line=1 width=1;
proc gplot data = means;
plot mean*Hour=Month / vaxis=axis1 haxis=axis2
noframe legend=legend1
autohref chref=graydd
autovref cvref=graydd;
format Month monfmt.;
run;
Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.
Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.
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.