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;

 

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 912 views
  • 0 likes
  • 2 in conversation