How do I break an axis in PROC SGPANEL? I need there to be less space where Month = 1 and Month = 3. Code follows:
proc sgpanel data= plot_dat noautolegend;
panelby TRTA ACAT1 / rows=2 columns=2 sort=(descformat descformat);
styleattrs datasymbols=(CircleFilled) datacontrastcolors=(black) datalinepatterns=(solid);
rowaxis min= 0 max=30 VALUES= (0 to 30 by 5) VALUESHINT grid minor GRIDATTRS=(color=ltgray pattern=solid);
colaxis VALUES= (0 1 3 ) vALUESHINT grid minor minorcount=2 GRIDATTRS=(color=ltgray pattern=solid);
series x= MONTH y= AVAL / group= SUBJID lineattrs=(thickness=2 color= black pattern=solid) ;
scatter x= MONTH y= AVAL / group= SUBJID markerattrs=(size=6pt);
run;
You can change the month value 1 into 2.5 and display it as month 2 by valuesdisplay= option:
P.S. You'd better post a real dataset and desired output graph to better illustrate your question, Otherwise,I would guess what you are looking for.
data have;
call streaminit(123);
do TRTA=1,2;
do ACAT1=1,2;
do SUBJID=1,2;
do month=0,2.5,3;
aval=rand('integer',0,30);
output;
end;
end;
end;
end;
run;
proc sgpanel data= have noautolegend;
panelby TRTA ACAT1 / rows=2 columns=2 sort=(descformat descformat);
styleattrs datasymbols=(CircleFilled) datacontrastcolors=(black) datalinepatterns=(solid);
rowaxis min= 0 max=30 VALUES= (0 to 30 by 5) VALUESHINT grid minor GRIDATTRS=(color=ltgray pattern=solid) ;
colaxis VALUES= (0 2.5 2.8 3 ) valuesdisplay=('0' '1' '2' '3') vALUESHINT grid minor minorcount=2 GRIDATTRS=(color=ltgray pattern=solid) ;
series x= MONTH y= AVAL / group= SUBJID lineattrs=(thickness=2 color= black pattern=solid) ;
scatter x= MONTH y= AVAL / group= SUBJID markerattrs=(size=6pt);
run;
By " I need there to be less space where Month = 1 and Month = 3." are you trying to make the whole axis shorter?
You can make the major tick marks equally spaced by using TYPE=DISCRETE on the COLAXIS statement but then the MINOR ticks go away. I do have to say that it sounds very odd to force 2 tick marks between values of a variable called Month.
Are you doing something odd with the overall size of the graph as a break would normally be desired where there is quite a range of values that would typically display on the xaxis without any y values for those. Skipping exactly one value in the range 0 to 3 sounds odd.
1. There are no data at month 2 so why have an axis point there? It is of no consequence and my customer does not want it.
2. Yes - I want less space between 1 and 3, e.g. an axis break.
@_Hopper wrote:
A discrete axis does not work because there are non-integer values on the time axis such as Day 1, 7, 14, etc. and my customer wants to see Month on the time axis.
Since your COLAXIS statement as shown in the code is
colaxis VALUES= (0 1 3 ) vALUESHINT grid minor minorcount=2 GRIDATTRS=(color=ltgray pattern=solid);
I have a very hard time believing that Day 1, 7 or anything actually appears on the graph unless you are using an annotate data set or something else. There chan be tick marks between 0 and 1 (2 exactly) but there is not going to be a label.
I'll believe that you don't want to use discrete.
SGPANEL and the COLAXIS do not apparently support the RANGE option that an XAXIS or YAXIS statement would use to create the breaks.
Suggestion: Provide a data step with some actual data and what you expect the result to look like.
You can change the month value 1 into 2.5 and display it as month 2 by valuesdisplay= option:
P.S. You'd better post a real dataset and desired output graph to better illustrate your question, Otherwise,I would guess what you are looking for.
data have;
call streaminit(123);
do TRTA=1,2;
do ACAT1=1,2;
do SUBJID=1,2;
do month=0,2.5,3;
aval=rand('integer',0,30);
output;
end;
end;
end;
end;
run;
proc sgpanel data= have noautolegend;
panelby TRTA ACAT1 / rows=2 columns=2 sort=(descformat descformat);
styleattrs datasymbols=(CircleFilled) datacontrastcolors=(black) datalinepatterns=(solid);
rowaxis min= 0 max=30 VALUES= (0 to 30 by 5) VALUESHINT grid minor GRIDATTRS=(color=ltgray pattern=solid) ;
colaxis VALUES= (0 2.5 2.8 3 ) valuesdisplay=('0' '1' '2' '3') vALUESHINT grid minor minorcount=2 GRIDATTRS=(color=ltgray pattern=solid) ;
series x= MONTH y= AVAL / group= SUBJID lineattrs=(thickness=2 color= black pattern=solid) ;
scatter x= MONTH y= AVAL / group= SUBJID markerattrs=(size=6pt);
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.