BookmarkSubscribeRSS Feed
☑ This topic is solved. 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 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

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

View all other training opportunities.

Discussion stats
  • 2 replies
  • 255 views
  • 4 likes
  • 2 in conversation