Dear team,
I have created Stored process by using below sas code to export excel file. When i tried to call stored process in SAS VA7.5 it showing below error:
1. Code used for stored process is:
2. Error message screen shot is attached
ods _all_ close;
data _null_;
rc=stpsrv_header('Content-type','application/vnd.ms-excel');
rc=stpsrv_header('Content-disposition',"attachment; filename=Class.xlsx");
run;
%let WORKPATH=%sysfunc(pathname(work));
filename temp "&WORKPATH/temp.xlsx";
proc export data=sashelp.class
outfile=temp
dbms=xlsx
replace;
sheet='mysheet';
run; quit;
data _null_;
infile temp recfm=f lrecl=1;
file _webout recfm=n;
input;
put _infile_;
run;
Change your content type header to use application/vnd.openxmlformats-officedocument.spreadsheetml.sheet. Your current content header is for xls files.
data _null_;
rc=stpsrv_header('Content-type','application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
rc=stpsrv_header('Content-disposition',"attachment; filename=Class.xlsx");
run;
Additionally, try modifying your data _null_ statement to use the code as described in Usage Note 20784 - Tip for downloading an existing binary file when running the SAS® Stored Process ...:
data _null_;
length data $1;
INFILE in recfm=n;
file _webout recfm=n mod;
input data $char1. @@;
put data $char1. @@;
run;
Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.
If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website.
See how to use one filter for multiple data sources by mapping your data from SAS’ Alexandria McCall.
Find more tutorials on the SAS Users YouTube channel.