BookmarkSubscribeRSS Feed
Calcite | Level 5
I am using a proc print in ods pdf output.

I would like the width of the columns to autofit to the size of the headers of the table instead of the size of the data. Or is it possible to set a larger width for each column of the table with the Style Option ?

Calcite | Level 5
This works :

Proc Print Data=temp label;
Id Obs / style=[just=center color=black fontsize=8PT];
Var &MyVar / style=[just=center color=black fontsize=8PT] style(column)={width=200};
Where %STR(&MyCondition);
Just a note. The "width=200" will end up having an impact on the HEADER cells (the COLUMN headers) -- as seen in the report below -- it doesn't matter whether I have long labels for the headers or short labels...the same width is used for all the cells. The concept of "autofit" is an Excel or spreadsheet concept. It usuallyl doesn't apply to ODS destinations like LISTING (which uses the format width) or ODS HTML, RTF and PDF. The width=200 may give the results you want in PDF, however, PDF output can also be impacted by the UNIFORM option, as well. Also, the width=200 may not work in other destinations the way it works for you in PDF. For example, in PDF, the long labels end up wrapping to the width of 200; but in HTML, the Header cells expands, as needed.

Also, as a best practice, it is a good idea with PROC PRINT and PROC REPORT to use a LOCATION in the STYLE override, such as:

(And, this posting doesn't seem to have anything to do with SAS/GRAPH or ODS GRAPHICS -- it seems more to apply to just ODS and Base SAS Reporting -- so in the future, you might want to post questions like this to the other ODS forum.)

data class;
set sashelp.class;
length longvar $400.;
longvar = 'Twas brillig and the slithy toves did gyre and gimble in the wabe. '||
'All mimsy were the borogroves and the mome raths outgrabe. '||
'Beware the Jabberwock, my son, the jaws that bite, the claws that snatch! ' ||
'Beware the Jubjub bird and shun the frumious Bandersnatch.';

ods listing close;

ods html file='c:\temp\pp.html' style=sasweb;
ods pdf file='c:\temp\pp.pdf' ;

Proc Print Data=class label;
title 'Note how style override without location applies to both header and data cells';
title2 'As seen with everything RED, CENTERED and 8 pt for NAME';
title3 'Also note how width of 200 is used -- no matter what value for HEADER is';
title4 'But you will get different results for HTML and PDF.';
Id name / style=[just=center backgroundcolor=red color=black fontsize=8PT];
Var sex age height weight longvar/
style(header)=[just=center color=black fontsize=8PT]
Where age gt 14;
label name = 'N'
height = 'H'
longvar='Jabberwocky by Lewis Carroll';
ods _all_ close;
Calcite | Level 5
Okay, thank you Cynthia.



Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

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.

Get the $99 certification deal.jpg



Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 2 in conversation