Hi,
How to right align an ISO date in the page header (Excel destination) using print_header= option?
Note that it works fine with the title statement
ods excel file="&xxtest./reporting/ods_excel_test.xlsx";
ods excel options(sheet_name='&R&D'
print_header='&R&D');
proc print data=sashelp.class noobs;
run;
ods excel options(sheet_name='%sysfunc'
print_header="%sysfunc(today(),e8601da.)");
proc print data=sashelp.class noobs;
run;
*issue;
ods excel options(sheet_name='&R %sysfunc'
print_header="&R %sysfunc(today(),e8601da.)");
proc print data=sashelp.class noobs;
run;
*works properly;
ods excel options(sheet_name='Title');
title '&R' "%sysfunc(today(),e8601da.)";
proc print data=sashelp.class noobs;
run;
ods excel close;
&D
but I don't know how to format it.%sysfunc(today(),e8601da.)
generated an ISO date but is centered here.&R %sysfunc(today(),e8601da.)
works but logically enough, the SAS systems tries to solve &R and a message is displayed when opening the Excel file. %nrstr(&R) does not solve the issue here.
Thanks in advance for any tips.
@Kurt_Bremser Your answer helped me realise that the issue could me my SAS installation. I've justed tested it on SAS On-Demand. It works there. So the issue is with my installation somehow. Cheers
When I use %NRSTR(&R) there are (of course) no messages in the log, and when I open the file in LibreOffice and use the print preview, the date is right-aligned.
Thanks @Kurt_Bremser
When I run the code I get the following error message when tempting to open the Excel file. Do you see any difference with your code?
ods excel file="&xxtest./reporting/ods_excel_test.xlsx";
ods excel options(print_header="%nrstr(&R) %sysfunc(today(),e8601da.)");
proc print data=sashelp.cars (obs=50) noobs;
run;
ods excel close;
@Kurt_Bremser Your answer helped me realise that the issue could me my SAS installation. I've justed tested it on SAS On-Demand. It works there. So the issue is with my installation somehow. Cheers
SAS On-Demand uses SAS 9.4 M6 I believe, so you'll need to upgrade to at least that in your local SAS installation.
ODS EXCEL is fairly new (and Excel is always a moving target), so it's no miracle that we repeatedly find (fixed) bugs or inconsistencies. Keeping SAS up-to-date is always a good idea.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.