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

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 5 replies
  • 728 views
  • 0 likes
  • 4 in conversation