BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
hjjijkkl
Pyrite | Level 9

How do you increase the width of a table in proc print output 

Number of Survey participants 
 

 

to 

Number of survey participants  

 

I used 

proc print data=have;

table survey record / style (column)=[width=Full];

 

but I keep on getting error. 

1 ACCEPTED SOLUTION

Accepted Solutions
mklangley
Lapis Lazuli | Level 10

Hi @hjjijkkl. I presume that is a column name you're working with?

 

If your column name has spaces in it, it looks like PROC PRINT will chose column width based on the longest value in the column. If your column header does not have spaces, PROC PRINT will chose column width based on the longest value or column header (so that nothing spills over into multiple lines).  Here are a couple examples that should help:

 

If your column name is lengthy and has spaces, it . Try using width=full.

 

data have1;
    input 'long column name with spaces'n $50.;
    datalines;
    test
    ;
run;

proc print data=have1; run;
proc print data=have1 width=full; run;

Output:

mklangley_0-1601316307047.png

Otherwise you could remove the spaces from your column names, and then you won't have this problem:

data have2;
    input long_column_name_without_spaces $50.;
    datalines;
    test
    ;
run;

proc print data=have2; run;
proc print data=have2 width=full; run;

Output:

mklangley_1-1601316328480.png

 

 

View solution in original post

2 REPLIES 2
ballardw
Super User

When you get errors you should copy the entire procedure or data step code with the errors and any notes from the LOG and then paste that into a code box opened on the forum with the </> icon to preserve formatting.

Example:

8       table sex /style=[width=full];
        -----
        180
ERROR 180-322: Statement is not valid or it is used out of
               proper order.
9    run;

NOTE: The SAS System stopped processing this step because of
      errors.
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds

Which very clearly says that you do not use Table in the position you have it.

Use VAR to indicate the variables to display. The style option Width should have a number and unit associated with it.

One example:

proc print data=sashelp.class;
   var sex / style =[width=4in]; 
   var age / style =[width=4in]; 
run;

You can use PCT as percent as a unit. Placing one style option with multiple variables will likely not accomplish what you want but try it.

mklangley
Lapis Lazuli | Level 10

Hi @hjjijkkl. I presume that is a column name you're working with?

 

If your column name has spaces in it, it looks like PROC PRINT will chose column width based on the longest value in the column. If your column header does not have spaces, PROC PRINT will chose column width based on the longest value or column header (so that nothing spills over into multiple lines).  Here are a couple examples that should help:

 

If your column name is lengthy and has spaces, it . Try using width=full.

 

data have1;
    input 'long column name with spaces'n $50.;
    datalines;
    test
    ;
run;

proc print data=have1; run;
proc print data=have1 width=full; run;

Output:

mklangley_0-1601316307047.png

Otherwise you could remove the spaces from your column names, and then you won't have this problem:

data have2;
    input long_column_name_without_spaces $50.;
    datalines;
    test
    ;
run;

proc print data=have2; run;
proc print data=have2 width=full; run;

Output:

mklangley_1-1601316328480.png

 

 

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 3994 views
  • 1 like
  • 3 in conversation