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

How can I assign a length to a column created by a tabulate statement?

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

If you assign the length before the SET statement, I believe it changes it in the data step.

 

Then you can modify it as necessary within the proc.

data want;
length var $60.;
set tabulate_out;

*blah blah blah;

run;

View solution in original post

6 REPLIES 6
Reeza
Super User

You can assign a format, I'm not sure about length.

 

n*var_x*f=8.1
ballardw
Super User

By Length I am assuming you mean the width of the column displayed. If you mean number of rows, which would be another way of thinking of "length" for a column, I haven't found anything other than severe data manipulation or obnoxious macro coding.

 

It depends to some extent on what type of column it represents.

If the variable is a Class variable then use a Classlev statement: Classlev Variablename/ style=[width=1in]; Note there are a number of units you can use, this is to create a one inch wide column. If the variable is stacked then the first (top) variable will control. Example:

Table variable1 variable2, someothervariable * n;

The width assigned to variable1 will usually control the width of the row header column.

You can set a table wide default on the tabulate statement with the stype option.

Sometimes I have had success with a width on a var statement as well: Var analysisvar / style=[width=.5in] but inconsistent depending on how I use that variable.

You can specify a width for a specific statistic as well.

Table variable1 variable2, someothervariable * n*{style=[width=.7in]

DavidPhillips2
Rhodochrosite | Level 12

I’m running into a scenario where I am outputting the contents of a tabulate.  One of the columns has a length of one when I output it.  But I want it to have a length of 60 when I use a datastep.

ballardw
Super User

Time to provide some example data and the code you are currently using. Also the ODS destination involved. So much could be done in a datastep that details are needed. And Proc Print does allow per variable style overrides to set column widths if that might be helpful.

Reeza
Super User

If you assign the length before the SET statement, I believe it changes it in the data step.

 

Then you can modify it as necessary within the proc.

data want;
length var $60.;
set tabulate_out;

*blah blah blah;

run;
DavidPhillips2
Rhodochrosite | Level 12

I was fairly over thinking it.  I just declared the length in the datastep after.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 6 replies
  • 1067 views
  • 1 like
  • 3 in conversation