The SAS Output Delivery System and reporting techniques

Adjusting column width when using Proc Tabulate

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 16
Accepted Solution

Adjusting column width when using Proc Tabulate

I am using Proc Tabulate with ODS PDF and one table created spans more than one page.  On the second page, the column widths adjust to fit which makes the table look unslightly.

 

I have tried using the cellwidth style attribute to fix the column size but it isn't working although code runs with no errors.

 

Can anyone help?  Code below.  

 

proc tabulate data=_tmp_country_t missing;
class hodo1 country year order;
var total;
format hodo1 $highdom.;
format order $orderout.;
table hodo1='' * [style= [cellwidth=7cm]] * country='', order ='' * year='' * total='' * sum='' * format=7. / misstext='0';
run;


Accepted Solutions
Solution
‎03-03-2016 03:41 AM
Super User
Posts: 11,134

Re: Adjusting column width when using Proc Tabulate

Are you trying to set the width of the 1)Row header variables (hodo country), or 2) the column header variables (order year) or 3) statistics?

Each level of nesting would need to be addressed. With Class variables usually the better approach is on a CLASSLEV statement:

 

Classlev hodo1 /style= [width=7cm] ; 

Set for each variable as needed.

 

If you need uniform column headings set them but watch for interactions due to NESTING.

Using ORDER * YEAR a specified width for ORDER would have to be large enough to handle all of the Years plus padding and such. Specifying a width for Year or the SUM statistic might be in order for uniformity.

 

 

 

 

View solution in original post


All Replies
Super User
Super User
Posts: 7,720

Re: Adjusting column width when using Proc Tabulate

Well I don't generally use tabulate anymore.  I would put the results out to a dataset, with an out=, then proc report it.  But looking at the code you give, inline style attribution has to be escaped e.g.:

ods escapechar='^';

title 'This title ^s={font-size=12} is big';

 

The ^ in this case is used as an escape character.

 

Solution
‎03-03-2016 03:41 AM
Super User
Posts: 11,134

Re: Adjusting column width when using Proc Tabulate

Are you trying to set the width of the 1)Row header variables (hodo country), or 2) the column header variables (order year) or 3) statistics?

Each level of nesting would need to be addressed. With Class variables usually the better approach is on a CLASSLEV statement:

 

Classlev hodo1 /style= [width=7cm] ; 

Set for each variable as needed.

 

If you need uniform column headings set them but watch for interactions due to NESTING.

Using ORDER * YEAR a specified width for ORDER would have to be large enough to handle all of the Years plus padding and such. Specifying a width for Year or the SUM statistic might be in order for uniformity.

 

 

 

 

Occasional Contributor
Posts: 16

Re: Adjusting column width when using Proc Tabulate

Works a treat!  Was trying to adjust the row variable headers.  Thanks for your help!

Super User
Posts: 9,875

Re: Adjusting column width when using Proc Tabulate

You can change the following system option to make your PDF size as big as you can hold all this tabulate.

 

options papersize=(10in 20in);



proc tabulate data=sashelp.class;
class sex age;
var weight;
tables sex*age,weight*(mean std);
run;
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 4 replies
  • 606 views
  • 1 like
  • 4 in conversation