BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
PaalNavestad
Pyrite | Level 9

Hi, I'm creating a plot where i want to label a point. 

The following program creates data and creates the plot 

data t;
	do i=0 to 60 by 1;
		month=intnx('month','01nov2017'd,i,'b');
		v= rand('normal');
		if i = 20 then do;
			v2=v;
			label='I want a text label.............................';
		end;
		else do;
			v2 = .;
			label='';
		end;

		output;
	end;
	format month date9.;
run;

proc sgplot data=t;
	scatter x=month y=v;
	
	text x=month y=v2 text=label/ position=topright;

	xaxis display=(nolabel) grid interval=month;
run;

When running the program as above the following appears

PaalNavestad_0-1635165863695.png

There is large unused space to he right.

If I run the program with topleft instead I get large unused space to the left instead.

Running with the position = Center 

PaalNavestad_1-1635166006894.png

I get unused space both left and right. 

 

My question is:

Are there any option(s) where I can avoid the large unused space?

If not is this a bug. It seems strange that the system set aside space that only will be used when the labels are at the end and is completely unnecessary when the labels are in the middle of the plot?

Thanks 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

Look at the CONTRIBUTEOFFSETS option on the TEXT plot. For your case, the best option is:

 

contributeoffsets = (ymin ymax)

 

That way, the text will not get clipped off along the top or bottom of your graph, but you will not get the extra space along the sides. Of, you can do:

 

contributeoffsets = none

 

since your labels are in the middle of your graph.

 

Hope this helps!

Dan

View solution in original post

2 REPLIES 2
DanH_sas
SAS Super FREQ

Look at the CONTRIBUTEOFFSETS option on the TEXT plot. For your case, the best option is:

 

contributeoffsets = (ymin ymax)

 

That way, the text will not get clipped off along the top or bottom of your graph, but you will not get the extra space along the sides. Of, you can do:

 

contributeoffsets = none

 

since your labels are in the middle of your graph.

 

Hope this helps!

Dan

PaalNavestad
Pyrite | Level 9

Thanks a lot worked like a dream. 

Pål N

 

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
  • 2 replies
  • 548 views
  • 4 likes
  • 2 in conversation