BookmarkSubscribeRSS Feed
Ryanb2
Quartz | Level 8

I need to define column width to standardize the look of the report.  However, when I set the column width it automatically expands the row height for each cell.  I tried setting the cellheight in various places in the code but I can't seem to constrain it.  How is this done?

 

Here's an example using the sashelp.cars dataset that gives me the same results.

 

ODS results off;
ODS listing close;  
ODS TAGSETS.EXCELXP
file="C:\test.xml"
STYLE=Printer
OPTIONS ( 
Sheet_Name = "NEW"
Orientation = 'landscape'
FitToPage = 'no'
Pages_FitWidth = '1'
Pages_FitHeight = '100' 
embedded_titles = 'yes'
);   
PROC REPORT DATA=sashelp.cars
style(header)=[fontfamily=helvetica fontsize=8pt textalign=l] 
style(column)=[fontfamily=helvetica fontsize=8pt textalign=l TAGATTR='format:text']; 
columns make model type origin msrp drivetrain horsepower mpg;
 
DEFINE make / STYLE(column)={width=2cm};
DEFINE model / STYLE(column)={width=2cm};
DEFINE type / STYLE(column)={width=2cm};
DEFINE origin / STYLE(column)={width=2cm};
DEFINE msrp / STYLE(column)={width=15cm};
DEFINE drivetrain / STYLE(column)={width=2cm};
DEFINE horsepower / STYLE(column)={width=2.5cm};
DEFINE mpg / STYLE(column)={width=2cm};
RUN;
ods tagsets.excelxp close;
4 REPLIES 4
ballardw
Super User

@Ryanb2 wrote:

I need to define column width to standardize the look of the report.  However, when I set the column width it automatically expands the row height for each cell.  I

 

Are you talking about values such as Model that have long text such as "3.5 RL w/Navigation 4dr" that wrap text to another line because it is too long to fit in space provided?

If so, what do you want to happen? Cutoff the extra text? Not wrap the text?

 

Note: SASHELP.CARS has MPG_City and MPG_Highway but not "MPG" as variables.

Ryanb2
Quartz | Level 8
Sorry. It looks like when I adapted my code to the cars dataset I didn't do it perfectly. Just trying to find a dataset users can run that creates wide column heights.

It's fine with me if the text is truncated in places. I can refine the widths if needed. If there's a way to make it wrap and expand dynamically without the egregious extra space then all the better.
ballardw
Super User

I'm afraid that you will have to more clearly describe, or provide a better data set, that demonstrates your specific concern.

 

Your comment "egregious extra space" without a concrete example isn't clear enough to code.

 

The ExcelXP (or other formats) generally will attempt to "dynamically fit" text into provide width columns by wrapping text too long to fit in a defined report column width. XML files may have an issue with which specific file viewer you use though. If you haven't looked at the generated XML in a text viewer you should to see just how much default stuff is set that the viewer gets to interpret.

 

Any particular reason you are using ODS ExcelXP for output?

Ksharp
Super User

You could use option "Row_Heights=".

 

ODS TAGSETS.EXCELXP
file="C:\temp\test.xls"
STYLE=Printer
OPTIONS ( 
Sheet_Name = "NEW"
Orientation = 'landscape'
FitToPage = 'no'
Pages_FitWidth = '1'
Pages_FitHeight = '100' 
embedded_titles = 'yes'

Row_Heights='0,40,0,0,0,0,0'

)   ;   
PROC REPORT DATA=sashelp.cars nowd
style(header)=[fontfamily=helvetica fontsize=8pt textalign=l] 
style(column)=[fontfamily=helvetica fontsize=8pt textalign=l TAGATTR='format:text']; 
columns make model type origin msrp drivetrain horsepower mpg;
 
DEFINE mpg / STYLE(column)={cellwidth=10cm};

RUN;
ods tagsets.excelxp close;

Ksharp_0-1715047613945.png

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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