Hi All,
I'm viewing the Stored process reports from Stored process Web application.
I tried the following code it's working fine for PDF, HTML and RTF fromats.
How Can I get Excel format report?
any suggestions..
[Pre] %if %upcase(&_odsdest)=PDF %then %do;
%let _odsstyle=printer;
%let _odsstylesheet=;
%let _odsoptions=bookmarkgen=no compress=9
startpage=no;
%end;
%else %if %upcase(&_odsdest)=RTF %then %do;
%let _odsstyle=rtf;
%let _odsstylesheet=;
%let _odsoptions=bodytitle startpage=no
nokeepn notoc_data;
%end;
You can use this code to create an XLSX file using SAS 9.4M3 and later:
ods _all_ close;
data _null_;
rc = appsrv_header('Content-type', 'application/vnd.ms-excel');
rc = appsrv_header('Content-disposition','attachment; filename="Class.xlsx"');
run;
ods Excel file=_webout style=HTMLBlue;
proc print data=sashelp.class; run; quit;
ods Excel close;
The older ExcelXP tagset works, too:
ods _all_ close;
data _null_;
rc = appsrv_header('Content-type', 'application/vnd.ms-excel');
rc = appsrv_header('Content-disposition','attachment; filename="Class.xml"');
run;
ods tagsets.ExcelXP file=_webout style=HTMLBlue;
proc print data=sashelp.class; run; quit;
ods tagsets.ExcelXP close;
Be sure to deselect Include code for Stored process macros in Step 2 of the SAS Enterprise Guide wizard, and select Stream in Step 3.
Vince DelGobbo
SAS R&D
Just to clarify, are you interested in creating a stored process, or a stored process report? They are two different things and the approach depends on which format that you need.
Also, what version of SAS are you running.
Vince DelGobbo
SAS R&D
>are you interested in creating a stored process, or a stored process report?
I'm creating Stored Process in Enterprise guide.. My requirement - I want the result in Excel format when I run it from Stored Process Web application.
>what version of SAS are you running?
SAS 9.4 M3
You can use this code to create an XLSX file using SAS 9.4M3 and later:
ods _all_ close;
data _null_;
rc = appsrv_header('Content-type', 'application/vnd.ms-excel');
rc = appsrv_header('Content-disposition','attachment; filename="Class.xlsx"');
run;
ods Excel file=_webout style=HTMLBlue;
proc print data=sashelp.class; run; quit;
ods Excel close;
The older ExcelXP tagset works, too:
ods _all_ close;
data _null_;
rc = appsrv_header('Content-type', 'application/vnd.ms-excel');
rc = appsrv_header('Content-disposition','attachment; filename="Class.xml"');
run;
ods tagsets.ExcelXP file=_webout style=HTMLBlue;
proc print data=sashelp.class; run; quit;
ods tagsets.ExcelXP close;
Be sure to deselect Include code for Stored process macros in Step 2 of the SAS Enterprise Guide wizard, and select Stream in Step 3.
Vince DelGobbo
SAS R&D
Thanks you so much @Vince_SAS. It's working
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.