BookmarkSubscribeRSS Feed
Jepi
Calcite | Level 5
Hi I am using PROC SGPLOT and have two reference lines (one at 40 and one at 50). Refline 40/axis=y Label = “Midterm” labelloc=inside labelpos=min;
Refline 50/axis=y Label = “Second Semester” labelloc=inside labelpos=min;

The problem I'm running into is the labels are overlapping. I want to position the label at 40 below the reference line and the label at 50 above its reference line.
3 REPLIES 3
ballardw
Super User

Easiest is just to change the LabelPos to one of of those to be MAX.

 

If you want to explicitly control the location of text I suggest adding observations to your data set to allow use of a TEXT plot statement with the X, Y location and a variable to hold the text. Then do not include a label on the line at all.  The Text plot would allow a few more options for displaying the text.

Jepi
Calcite | Level 5
Thanks! With setting one to MAX and the other to MIN. The 50 refline still runs through the 40 refline label.

Does X and Y have to be numeric?
ballardw
Super User

@Jepi wrote:
Thanks! With setting one to MAX and the other to MIN. The 50 refline still runs through the 40 refline label.

Does X and Y have to be numeric?

Now we are at the point where you should provide an example of the data set you are using for proc sgplot and the entire code of the Sgplot used.

 

Refline values do not have to be numeric but if you are using a character value for the line that it is not one of the actual values results are at best unpredictable and likely to not appear at all.

Example of a not very useful graph but shows use of text values for refline when the axis is character:

Proc sgplot data=sashelp.cars;
   scatter x=make y=type;
   refline 'Isuzu' /axis=x  ;
   refline 'Sedan' /axis=y ;
run;

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 1107 views
  • 0 likes
  • 2 in conversation