The SAS Output Delivery System and reporting techniques

Defining Column widths with Proc Report and ODS

Reply
N/A
Posts: 0

Defining Column widths with Proc Report and ODS

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?
SAS Super FREQ
Posts: 8,866

Re: Defining Column widths with Proc Report and ODS

Posted in reply to deleted_user
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
Ask a Question
Discussion stats
  • 1 reply
  • 1620 views
  • 0 likes
  • 2 in conversation