BookmarkSubscribeRSS Feed
jsbyxws
Obsidian | Level 7

Hi, 

 

I created a simple AE example to show my problems. In SGPlot for highlow, y=AEDECOD. When y axis option of display "novalues" is commented, it does show AEDECOD on the left. But some AEDECOD is long, I want to wrap it for example "Influenza" (wrap) "like illness". Is there any way to do it? Below is my code. 

 

Thanks a lot for reading and help!

 

data AE;
	length AEDECOD $200;
	AEDECOD='Influenza like illness';AESTDY=1;AEENDY=10;output;
	AEDECOD='Haemarthrosis';AESTDY=3;AEENDY=14;output;
run;

proc sgplot data=AE; highlow y=AEDECOD low=AESTDY high=AEENDY / type=bar lineattrs=(color=black pattern=solid) barwidth=0.8; xaxis grid display=(nolabel) values=(0 to 15); yaxis grid display=(noticks /*novalues*/ nolabel); run;

 

5 REPLIES 5
Rick_SAS
SAS Super FREQ

1. Choose a "split character". I will use '/'.

2. Insert the split character where you want the string to split.

3. Add FITPOLICY=SPLITALWAYS SplitChar='/' to the YAXIS statement.

 

data AE;
	length AEDECOD $200;
	AEDECOD='Influenza/like illness';AESTDY=1;AEENDY=10;output;
	AEDECOD='Haemarthrosis';AESTDY=3;AEENDY=14;output;
run;

proc sgplot data=AE;		
	highlow y=AEDECOD low=AESTDY high=AEENDY 
		/ type=bar lineattrs=(color=black pattern=solid) barwidth=0.8;		
	xaxis grid display=(nolabel) values=(0 to 15);
	yaxis grid display=(noticks /*novalues*/ nolabel) 
              fitpolicy=SplitAlways splitchar='/';		
run;

jsbyxws
Obsidian | Level 7

Thanks a lot for help! It works great. I tried fitpolicy=split and split='/' but it did not work. 

ballardw
Super User

@jsbyxws wrote:

Thanks a lot for help! It works great. I tried fitpolicy=split and split='/' but it did not work. 


If the fitpolicy=split is used the split only takes place when the text is "long", meaning that the current space used for the tick value is not long enough to hold the value on a single line. So when "Influenza / like illness" fits on a line it isn't split. But "Influenze like / longer text" might.

This is dependent on size of graph and other options like font size so is a bit problematic for reliable splitting of "short" values.

jsbyxws
Obsidian | Level 7

Oh. That's why! Thanks for the explanation.

JeffMeyers
Barite | Level 11
The SPLITALWAYS only works when the axis type is discrete. Try adding type=discrete to your YAXIS statement. If you're using numeric coded values it might be using a linear one instead.

SPLITALWAYS

always splits the values at the character or characters specified in the SPLITCHAR= option. If the value does not contain any of the specified split characters, a split does not occur.
Default The default split character is a space.
Restriction This option has no effect unless the axis is discrete.
Tip You can specify the split character using the SPLITCHAR= option.
Example Fit Policies for Axes

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 5 replies
  • 1032 views
  • 0 likes
  • 4 in conversation