BookmarkSubscribeRSS Feed
deleted_user
Not applicable
If I understand it correctly the width= parameter in the Define statement does not work with ODS which I guess makes sense since my font is proportional (Times 9pt). I have tried using cellwidth= in my style(column) statement but I end up using the trial and error method of finally determining the size - Usually I don't miond if the data wraps as long as the column header doesn't wrap. And sometimes if I increase the size of one column it decreases the size of another column - essentially ignoring the cellwidth of that column.

Can anyone help me understand how ODS determines the column width and what I need to do to make this process easier?
1 REPLY 1
Cynthia_sas
SAS Super FREQ
Hi:
I find that cellwidth is frequently trial and error -- if you don't use cellwidth on -every- variable or report item, then the other report items -can- shift in width.

ODS calculates the cellwidth of the cells based on a variety of factors: first and foremost, the destination, then the font being used for the headers versus the font being used for the data cells, the number of characters in the header and data cells (in some destinations), the cellpadding being used for the table, any style changes that need to be applied. There is no formula that will save you eyeballing the report and making adjustments.

I find that with ODS HTML, the issue of cellwidth is moot, because an ODS HTML output report can be as wide as it needs to be. For ODS RTF and ODS PDF, I find I can generally get ODS to do what I want by fiddling with font_size and cellpadding instead of fiddling with cellwidth -- or by setting ORIENTATION to LANDSCAPE. For other ODS destinations, like ODS CSV or ODS TAGSETS.EXCELXP, the cellwidth that you set with style attributes is frequently not used (ODS CSV) or sometimes ignored (TAGSETS.EXCELXP) by Excel.

The best thing to do is to allow ODS to set whatever cellwidth it calculates -- that way when your data changes, you're not locked into what might be an inappropriate cellwidth.

One way -around- using cellwidth is to use OUTPUTWIDTH or WIDTH on the whole report:
[pre]
proc report data=xxx.yyy nowd
style(report)={outputwidth=100%};
[/pre]

But, if you use OUTPUTWIDTH to tell ODS that it's OK to stretch the table out to 100%, you are also trusting ODS to set each column's cell widths as it calculates. I would recommend against using OUTPUTWIDTH for the whole report and CELLWIDTH for individual columns.

Generally speaking, column header cells are in bold or sometimes bigger font than the data cells -- so this can make them not fit when the data does seem to fit when ODS calculates the cell width. One thing you can try is:
[pre]
define varname / style(header)={font_size=9pt font_weight=bold}
style(column)={font_size=9pt font_weight=medium};
[/pre]

Note that the above style attribute names are the names that will work in either SAS 9.1.3 -or- SAS 9.2. If you look in the documentation, at the site:
Style Attributes and Their Values
http://support.sas.com/documentation/cdl/en/odsug/61723/HTML/default/a002972093.htm

you will notice that the attribute names for 9.2 can be specified differently, FONTWEIGHT instead of FONT_WEIGHT and FONTSIZE instead of FONT_SIZE, for example, but if you are not on 9.2, you should use the older attribute names.

cynthia

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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
  • 1 reply
  • 7990 views
  • 0 likes
  • 2 in conversation