BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Bill3
Fluorite | Level 6

I want to achieve this effect in the image in RTF (the column width is set to 4 characters, and the line will wrap when it is reached). Please check whether my width is set incorrectly.

17307148294013.png

ods rtf file="xxx\test.rtf" style=rtf;

proc report data = sashelp.cars;
        column make model;
        define make / width=4;
        define model / width=4;
run;
ods rtf close;
1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

First, it may be time to describe what the real problem that this solution addresses as it sounds very awkward at best and possibly very ugly in reality.

 

Since your PICTURE shows 1) Text for Make that is a much larger font than for Model and 2) "wraps" text for Make without affecting the line alignment for Model the first thing would likely be that MAKE be defined as a GROUP variable and use the Proc option SPANROWS:

 

proc report data = sashelp.cars spanrows;
        column make model;
        define make / group  width=4;
        define model / width=4;
run;

If I really wanted that appearance I would never rely on a "width" setting, either number of characters or cellwidth measured widths because changes of style, fonts and such make it very hard to be consistent. I would instead be tempted to insert breaking space.

 

Also you need to consider what is the actual length of your longest value? I have to assume that you are using Sashelp.cars as an example for your data set. What if you have a long value, say up to 16 characters that would wrap to 4 lines but there are only two categories of the "Model" equivalent variable. Then you have an odd appearance.

 

Additionally the display width of the individual letters may become of interest. Almost all output these days uses proportional fonts and something that looks "reasonable" for some combinations of letters may not for other. Consider four wide characters compared with four skinny ones.

 

WWWW

iiii

note that the four letter i above take up less space than two letter W. So something with skinny characters may look funny displayed in the manner you suggest, wrapped at four characters, or the sequence of W might really want to be wrapped at three to maintain your appearance.

View solution in original post

2 REPLIES 2
Kurt_Bremser
Super User

From the documentation of the WIDTH= option of the DEFINE statement:

Restriction This option has no effect on ODS destinations other than LISTING output. For ODS destinations, use the STYLE= option with the WIDTH= style attribute or the CELLWIDTH= style attribute. Refer to Style Attributes Tables in SAS Output Delivery System: Advanced Topics for details. See how style attributes WIDTH= and CELLWIDTH= can be used with PROC REPORT in Using the CELLWIDTH= Style Attribute with PROC REPORT
ballardw
Super User

First, it may be time to describe what the real problem that this solution addresses as it sounds very awkward at best and possibly very ugly in reality.

 

Since your PICTURE shows 1) Text for Make that is a much larger font than for Model and 2) "wraps" text for Make without affecting the line alignment for Model the first thing would likely be that MAKE be defined as a GROUP variable and use the Proc option SPANROWS:

 

proc report data = sashelp.cars spanrows;
        column make model;
        define make / group  width=4;
        define model / width=4;
run;

If I really wanted that appearance I would never rely on a "width" setting, either number of characters or cellwidth measured widths because changes of style, fonts and such make it very hard to be consistent. I would instead be tempted to insert breaking space.

 

Also you need to consider what is the actual length of your longest value? I have to assume that you are using Sashelp.cars as an example for your data set. What if you have a long value, say up to 16 characters that would wrap to 4 lines but there are only two categories of the "Model" equivalent variable. Then you have an odd appearance.

 

Additionally the display width of the individual letters may become of interest. Almost all output these days uses proportional fonts and something that looks "reasonable" for some combinations of letters may not for other. Consider four wide characters compared with four skinny ones.

 

WWWW

iiii

note that the four letter i above take up less space than two letter W. So something with skinny characters may look funny displayed in the manner you suggest, wrapped at four characters, or the sequence of W might really want to be wrapped at three to maintain your appearance.

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
  • 2 replies
  • 451 views
  • 1 like
  • 3 in conversation