The SAS Output Delivery System and reporting techniques

Adjusting column width when using Proc Tabulate

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 14
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
Grand Advisor
Posts: 9,748

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
Esteemed Advisor
Esteemed Advisor
Posts: 6,726

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
Grand Advisor
Posts: 9,748

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: 14

Re: Adjusting column width when using Proc Tabulate

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

Grand Advisor
Posts: 9,336

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;
Post a Question
Discussion Stats
  • 4 replies
  • 420 views
  • 1 like
  • 4 in conversation