BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Haris
Lapis Lazuli | Level 10

Is there a way to tell SAS to treat dashed-words as two separate words when determining when to insert a line break?  Currently, a 'dashed-word' is treated as a single word and, at the end of the line, line-break is not inserted after the dash--the whole dashed-word is moved to a new line if it does not fit.  There must be an option that would tell SAS to leave 'dashed-' at the end of the line and place 'word' on the new line.  Currently, I am inserting a space between the dash '-' and the word 'word'.

 

Thanks,

Haris

 

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Try placing both characters in the SPLITCHAR option.

When I run your code on SAS 9.4 modified as

proc sgplot data=g;
vbar Cat / response=Value;
xaxis fitpolicy=splitalways splitchar='- ' splitcharnodrop ;
run;


each of the labels are displayed as three rows and the dashes are displayed at the end of the split as needed.

 

View solution in original post

8 REPLIES 8
PaigeMiller
Diamond | Level 26

What SAS PROC or application (e.g. Visual Analytics) are you doing this in?

--
Paige Miller
Haris
Lapis Lazuli | Level 10

Multiple procs.  Specifically, I used in PROC SGPLOT as a value label, PROC REPORT as a column header as well as a row header, PROC ODSTEXT, etc.  If there are PROCs that support this kind of functionality and others that don't, I'd like to know that too.

 

EDIT: so, apparently, both PROC PRINT and PROC report do this correctly with text in the cells--they both break a line at the dash.  PROC SGPLOT does not break at the dash when labeling values on x axis.  I will need to double-check how dash is treated in PROC REPORT column headers.

PaigeMiller
Diamond | Level 26

In PROC REPORT, I myself tell it where to place line breaks in the column headers. I haven't done this in PROC SGPLOT, so that's something you can try yourself.

 

ods escapechar='^';

proc report data=sashelp.class;
    columns name;
	define name/group "What is^{newline 1}the Student's^{newline 1}Name?";
run;

I realize that's not exactly the same as what you are asking for, where SAS does the splitting at a hyphen automatically.

 

 

--
Paige Miller
Haris
Lapis Lazuli | Level 10

Yes, thanks.  EscCharacter is what I am using now on an ad hoc basis.  But, as you noted, that's not what I need.  In my case, what is printed is a format for a numeric value.  I need it to work across multiple different deployments.  Forcing a line-break is not what I want when it is used as a row header.

ballardw
Super User

Show your 1) proc sgplot code 2) example data and 3) tell us which release of SAS you are using.

 

Since you say this is for an axis label then the appropriate axis statement can use the SPLITCHAR SPLITCHARNODROP and SPLITJUSTIFY options if using 9.4 (at least) or later. You may have issues related to FITPOLICY if you are attempting to display a lot of values also.

 

Also there is a potential issue of exactly which "dash" character is in your data versus the code you submit. The "-" on the keyboard for programming may not be an emdash or other word processing/ Unicode character dash in your data.

Haris
Lapis Lazuli | Level 10

Thanks Ballardw,

 

This very close to what I need.  I did not know about the SPLITCHARNODROP.  Very useful.  Only one problem remains: I need the program to treat a *space* as a break as well as the *hyphen* character.  I need the labels to split into three lines.  Is there a way to specify more than one SPLITCHAR?

 

I can't rotate the value labels as the y-axis space is at a premium and x-axis categories can be wordy.

 

data g;
input Cat$ 16. Value;
cards;
OneH-TwoH Three1 4
One Two Three2   3
OneH-TwoH Three3 2
One Two Three4   1
OneH-TwoH Three5 4
One Two Three6   5
OneH-TwoH Three7 2
One Two Three8   3
;


proc sgplot data=g;
vbar Cat / response=Value;
xaxis fitpolicy=splitalways splitchar='-' splitcharnodrop;
run;

ballardw
Super User

Try placing both characters in the SPLITCHAR option.

When I run your code on SAS 9.4 modified as

proc sgplot data=g;
vbar Cat / response=Value;
xaxis fitpolicy=splitalways splitchar='- ' splitcharnodrop ;
run;


each of the labels are displayed as three rows and the dashes are displayed at the end of the split as needed.

 

Haris
Lapis Lazuli | Level 10
Brilliant! Done and Done!

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
  • 8 replies
  • 1932 views
  • 2 likes
  • 3 in conversation