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

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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