BookmarkSubscribeRSS Feed
phil27
Calcite | Level 5
Hi,
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 ?

Thanks.
3 REPLIES 3
phil27
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);
Run;
Cynthia_sas
SAS Super FREQ
Hi:
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:
[pre]
style(header)={color=black}
style(column)={color=blue}
[/pre]

(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.)

cynthia
[pre]
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.';
run;

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]
style(column)={width=200};
Where age gt 14;
label name = 'N'
height = 'H'
age='SUPERCALIFRAGILISTICEXPEALIDOCIOUS'
longvar='Jabberwocky by Lewis Carroll';
Run;
ods _all_ close;
[/pre]
phil27
Calcite | Level 5
Okay, thank you 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
  • 3 replies
  • 4692 views
  • 0 likes
  • 2 in conversation