BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Micheal_S
Calcite | Level 5

Hello..

 

I am trying to create a stored process, in which i have to just grab already created excel report from the server and produce the same (without any changes) as an output of the stored process execution. i am trying to do this using stpsrv_header but its not working.

 

data _null_;
rc= stpsrv_header('Content-type', 'application/vnd.ms-excel');
rc= stpsrv_header('Content-disposition', 'attachment;
filename=outtest.xls');
run;

 

Did anyone tried this before? Please let me know.

 

Thanks,

Mike

1 ACCEPTED SOLUTION

Accepted Solutions
boemskats
Lapis Lazuli | Level 10

Michael,

 

This should work. Have a look at the second half of this post that I wrote ages ago.

 

You need to use the STP webapp, you need to have Streaming output enabled. Here's the code from the other post.

  filename myFileInput="/myTempFileLocation/&filenameParameter..xml";
  %let RV=%sysfunc(stpsrv_header(Content-type,application/vnd.ms-excel));
  %let RV=%sysfunc(stpsrv_header(Content-disposition,attachment; filename= Histostaffperformance.xml));
  data outmenow;
    length data $1;
    infile myFileInput recfm=n;
    file _webout recfm=n mod;
    input data $char1. @@;
    put data $char1. @@;
  run;

Good luck.

 

Nik

View solution in original post

5 REPLIES 5
Micheal_S
Calcite | Level 5

Yes Kurt, I tried it. 

 

rc = stpsrv_header('Content-disposition','attachment; filename="test.xls"');

 

Its not giving me any error message but not doing what i intended for. Its just getting executed successfully and no result is coming out. 

LinusH
Tourmaline | Level 20
Since this doesn't involve any SAS processing the feels a bit unnecessary to use a Stored Process. Consider using other Web aplication server functionality for this.
Data never sleeps
boemskats
Lapis Lazuli | Level 10

Michael,

 

This should work. Have a look at the second half of this post that I wrote ages ago.

 

You need to use the STP webapp, you need to have Streaming output enabled. Here's the code from the other post.

  filename myFileInput="/myTempFileLocation/&filenameParameter..xml";
  %let RV=%sysfunc(stpsrv_header(Content-type,application/vnd.ms-excel));
  %let RV=%sysfunc(stpsrv_header(Content-disposition,attachment; filename= Histostaffperformance.xml));
  data outmenow;
    length data $1;
    infile myFileInput recfm=n;
    file _webout recfm=n mod;
    input data $char1. @@;
    put data $char1. @@;
  run;

Good luck.

 

Nik

Micheal_S
Calcite | Level 5

Hi Boemskats,

 

Thank you, 

Greatly appreciate it.

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 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 1430 views
  • 0 likes
  • 4 in conversation