BookmarkSubscribeRSS Feed
elsfy
Quartz | Level 8

Hi, 

I couldn't find an appropriate solution to my problem and maybe i am confusing height/width options..

 

I am doing a proc report that i want to export to excel with ODS EXCEL.

Even if the results shown in the HTML  output are fine, when exporting to excel, it's not giving the  expected output.

I have headers, columns,... and some should have a  different size than others in excel.

 

What i want to be displayed is something like this (due to confidentiality x corresponds to text and 999 999 to different numbers that can go from 0 to billions) :

 

isgnr_1-1653055868419.png

If you pay attention, the columns don't have same size. I need the first 3 one (with text) to be longer than the ones with numbers. Plus, ROW 7 contains headers so i want the entire row to be bigger than cell with values. 

 

I've tried many options, from playing with style(column)=[width...] to adding options to ODS EXCEL and here is the last thing that i did: 


title1 color=blue bcolor=blue ''; 
title2 color=blue bcolor=blue '';
title3 color=blue bcolor=blue ''; 
 
ods excel file ="..xlsx" 
	options(embedded_titles='yes'  hidden_rows='4' flow="header,data,tables" blank_sheet="INFORMATION"
absolute_column_width='15,10,15,10,10,10,10,10' absolute_row_height='15' ) ;

ods escapechar= '^' ;
options missing=0 orientation=landscape center;
proc report data= data split='~' nowd center style(header)={ background=white borderwidth=1 bordercolor=black color=black /*width=150*/ just=c textalign=c tagattr="wrap:no" vjust=m asis=on} style(report)={borderwidth=1 bordercolor=black just=r} style(column)= { borderwidth=1 bordercolor=black just=r color=black tagattr='format:###,###,###,###,###0' } style(summary)= [just=c textalign=c]; column ('^{style[color=red]location xxxxxx}' var1 var2 var3 var4 var5 ...) ; define var1 / group width=132 ; define var2 / group style(column)=[width=2.5in]; define var3 / group ; define var4 / analysis sum ; define var5 / analysis sum ; .... /analysis sum ; run ;

What i get is this kind of output : 

isgnr_2-1653056480667.png

 

1) This the size i want for row values but not for headers in row 7 because we can't read the entire header. I think that in the ods excel instruction 'ABSOLUTE_ROW_HEIGHT = 15' is applied to the entire sheet.

2) I think that i am missing or misunderstanding some things : width, cellwidth , height options...

3) The best result that i would like is that excel adjust automatically each column and row to its content when exporting just like it is possible to do it so manually in excel.

 

Sorry if it's a bit confusing. I can't provide data or the entire code due to confidentiality.

Best,

 

 

2 REPLIES 2
average_joe
Obsidian | Level 7

This is an example of how I control the cell width when using ODS EXCEL:

 

define business_name / 'Business Name' style(column)=[cellwidth=1.25in];
Ksharp
Super User

title1 color=blue bcolor=blue ''; 
title2 color=blue bcolor=blue '';
title3 color=blue bcolor=blue ''; 
ods escapechar= '^' ;
ods excel file='c:\temp\want.xlsx' options(sheet_name='class' embedded_titles='yes'  hidden_rows='4');
proc report data=sashelp.class nowd style(header)={cellheight=2cm};
column ('^{style[color=red]location xxxxxx}' name sex weight height) ;
define name/display style={cellwidth=2cm};
define sex/display style={cellwidth=2cm};
define weight/display style={cellwidth=1cm};
define height/display style={cellwidth=1cm};
run;
ods excel close;

Ksharp_0-1653130014784.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
  • 2 replies
  • 1438 views
  • 1 like
  • 3 in conversation