When I run the below code it is opening in Excel. The "# of coils" data is left justified in excel.
I want it to be center justified. Any help would be appreciated.
proc report data=WORK.APPEND_TABLE_0038 nowd
STYLE(REPORT)={rules=all cellspacing=0 bordercolor=black}
;
column color no_of_coils ;
TITLE1 "<td align=left colspan=5 ><font size=4 color=black><b>Rust Prevention Report: %TRIM(%QSYSFUNC(DATE(), NLDATE20.))</b></font></td>";
TITLE2 "<td align=center colspan=5 ><font size=3 color=black><b>TPC Slit Coils</b></font></td>";
TITLE3 "<td align=center colspan=5 ><font size=2 color=black><b>6-10 Yellow; More than 10 Red</b></font></td>";
compute no_of_coils;
if color = 'yellow'
then
call define ('no_of_coils','style','style=[background=yellow]');
if color = 'red'
then
call define ('no_of_coils','style','style=[background=red]');
endcomp;
define no_of_coils / display '# of coils';
define color / display noprint;
;
run;
Please show the code that sends this to Excel, ODS EXCEL, TAGSETS.EXCELXP, MSOffice, html being opened with Excel, something else. The different methods of sending to Excel sometimes require different approaches to get the desired appearance.
Hi:
Some sample code with SASHELP.CLASS illustrates how to do centering. I did each column as centered and varied the headers so you could see the impact. When I use ODS EXCEL or TAGSETS.EXCELXP, the results are the same...
cynthia
Here's the code:
ods excel file='c:\temp\o_x_new.xlsx' style=htmlblue;
ods tagsets.excelxp file='c:\temp\o_t_xp.xml' style=htmlblue;
proc report data=sashelp.class;
column name age sex;
define name /
style(header)={just=left cellwidth=1.0in}
style(column)={just=center cellwidth=1.0in};
define age /
style(header)={just=right cellwidth=1.0in}
style(column)={just=center cellwidth=1.0in};
define sex /
style(header)={just=center cellwidth=1.0in}
style(column)={just=center cellwidth=1.0in};
run;
ods _all_ close;
GOPTIONS ACCESSIBLE;
%LET RV=%SYSFUNC(APPSRV_HEADER(CONTENT-TYPE,APPLICATION/VND.MS-EXCEL)));
ODS PATH work.templat(update) WORK.templat(read) sashelp.tmplmst(read);
PROC TEMPLATE;
DEFINE STYLE STYLES.TEST;
STYLE TABLE /
borderwidth=1
bordercolor=black
font_face=black;
END;
RUN;
ODS LISTING CLOSE;
ODS HTML BODY=_WEBOUT STYLE=STYLES.TEST;
Also, I probably wasn't clear enough. The whole column needs to be centered on the page. Currently when opening the one column displays in column A in the spreadsheet (all the way to the left). Is there a way to center this one column on the page?
Hi Cynthia,
I downloaded excelxp tagset. I now have the following code.
Is it possible to center the column "# of coils" to the center of the excel spreadsheet? I cannot select a column like you suggested above because I have other proc reports that will display on the same sheet with more columns which will then cause this first proc report to still look aligned to the left.
Also, my title does not display because it only displays to the width of the column "# of coils." If I make the cellwidth larger of the column I can get the full title to display. Any advice on this also?
GOPTIONS ACCESSIBLE;
%LET RV=%SYSFUNC(APPSRV_HEADER(CONTENT-TYPE,APPLICATION/VND.MS-EXCEL));
%LET RV=%SYSFUNC(APPSRV_HEADER(CONTENT-DISPOSITION,ATTACHMENT; FILENAME="RUST_RPT_%sysfunc(today(),MMDDYY8.).XLS"));
ODS PATH work.templat(update) sasuser.templat(read) sashelp.tmplmst(read);
ods listing close;
ODS tagsets.excelxp file=_WEBOUT style=styles.journal_borders
options(sheet_interval='none' sheet_name='Rust'
embedded_titles='yes' orientation='portrait' suppress_bylines='yes');
proc report data=WORK.APPEND_TABLE_0038 nowd;
column color no_of_coils ;
TITLE1 f='Calibri' h=12pt "Rust Prevention Report: %TRIM(%QSYSFUNC(DATE(), NLDATE20.))";
TITLE2 f='Calibri' h=11pt "TPC Slit Coils";
TITLE3 f='Calibri' h=10pt "6-10 days: Yellow > 10 days: Red";
compute no_of_coils;
if color = 'yellow'
then
call define ('no_of_coils','style','style=[background=yellow]');
if color = 'red'
then
call define ('no_of_coils','style','style=[background=red]');
endcomp;
define no_of_coils / display '# of coils';
define color / display noprint;
;
run;
Thank you Cynthia. I have submitted a ticket.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.