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: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

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