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: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

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
  • 1569 views
  • 0 likes
  • 4 in conversation