BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Richard5
Calcite | Level 5

Hi,

 

I would like to know if it is possible to position REFLINE label outside of plot area in PROC SGPANEL. Based on SAS documentation it seems only possible in PROC SGPLOT, where labelloc option can be defined.

 

See following example:

Richard5_1-1719581975581.pngRichard5_2-1719581988520.png

/* create rudimentary dataset */
data have(drop=i);
call streaminit(123);
format Date date9.;
do i=0 to 24;
	do Country=1 to 3;
		do Category=1 to 4;
			Date=intnx('month','31dec2020'd,i,'end');
			n=rand('normal',100,5);
			output;
		end;
	end;
end;
run;

/* SGPANEL with REFLINE labels inside the plot area */
ods graphics / width=600 height=300;
proc sgpanel data=have pctlevel=group;
panelby Country / columns=3;
vbar Date / response=n group=Category stat=percent;
colaxis type=time;
refline '30jun2021'd / axis=x label='REF 1' label;
refline '31dec2021'd / axis=x label='REF 2';
run;

/* SGPLOT with REFLINE labels outside the plot area */
proc sgplot data=have(where=(country=1)) pctlevel=group;
vbar Date / response=n group=Category stat=percent;
xaxis type=time;
refline '30jun2021'd / axis=x label='REF 1' labelloc=outside;
refline '31dec2021'd / axis=x label='REF 2' labelloc=outside;
run;
ods graphics / reset;

P.S. of course, I can do loop and instead of PROC SGPANEL do multiple PROC SGPLOTs, but that is not my question.

 

Thanks for any help,

Richard

1 ACCEPTED SOLUTION

Accepted Solutions
Rick_SAS
SAS Super FREQ

No, it isn't possible. The documentation for the REFLINE statement in PROC SGPANEL shows that the only option for the label is the LABELPOS= option, which controls whether the label is on the left/right or bottom/top. There is not an option to put the label outside the plot area.

 

Think about a 3x3 panel, there isn't really an "outside" region for the middle plot. Similarly, plots along the first column don't have an "outside-right" region.  

 

Just to be sure, I checked the doc for the REFERENCELINE statement in the GTL, which is the underlying source for the REFLINE statements in PROC SGPANEL. Although there is a CURVELABELLOCATION= option, the doc states the the option is not available for paneled plots:

Restriction OUTSIDE cannot be used when the REFERENCELINE is used in multicell layouts such as LATTICE, DATAPANEL, or DATALATTICE, where axes might be external to the grid.

 

View solution in original post

3 REPLIES 3
Rick_SAS
SAS Super FREQ

No, it isn't possible. The documentation for the REFLINE statement in PROC SGPANEL shows that the only option for the label is the LABELPOS= option, which controls whether the label is on the left/right or bottom/top. There is not an option to put the label outside the plot area.

 

Think about a 3x3 panel, there isn't really an "outside" region for the middle plot. Similarly, plots along the first column don't have an "outside-right" region.  

 

Just to be sure, I checked the doc for the REFERENCELINE statement in the GTL, which is the underlying source for the REFLINE statements in PROC SGPANEL. Although there is a CURVELABELLOCATION= option, the doc states the the option is not available for paneled plots:

Restriction OUTSIDE cannot be used when the REFERENCELINE is used in multicell layouts such as LATTICE, DATAPANEL, or DATALATTICE, where axes might be external to the grid.

 

Richard5
Calcite | Level 5
Alright, thank you!
Ksharp
Super User

You could make more OFFSET at Y axis top to display this label.

 

ods graphics / width=600 height=300;
proc sgpanel data=have pctlevel=group;
panelby Country / columns=3;
vbar Date / response=n group=Category stat=percent;
colaxis type=time;
rowaxis offsetmax=0.1;
refline '30jun2021'd / axis=x label='REF 1' label;
refline '31dec2021'd / axis=x label='REF 2';
run;

Ksharp_0-1719650303414.png

 

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 765 views
  • 1 like
  • 3 in conversation