BookmarkSubscribeRSS Feed
ShammiKalsi
Fluorite | Level 6

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 STored process error.PNG

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;

 

1 REPLY 1
Stu_SAS
SAS Employee

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;

 

 

SAS Innovate 2025: Call for Content

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!

Submit your idea!

Tips for filtering data sources in SAS Visual Analytics

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.

Discussion stats
  • 1 reply
  • 694 views
  • 0 likes
  • 2 in conversation