Your SAS programs, embedded in web apps and elsewhere

Accessing Excel file from server and generate the same as an output to the stored process.

Accepted Solution Solved
Reply
Contributor
Posts: 36
Accepted Solution

Accessing Excel file from server and generate the same as an output to the stored process.

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


Accepted Solutions
Solution
‎08-31-2016 05:56 AM
Frequent Contributor
Posts: 91

Re: Accessing Excel file from server and generate the same as an output to the stored process.

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


All Replies
Super User
Posts: 6,928

Re: Accessing Excel file from server and generate the same as an output to the stored process.

Have you tried my suggestion I gave you in the other thread about the same issue?

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Contributor
Posts: 36

Re: Accessing Excel file from server and generate the same as an output to the stored process.

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. 

Super User
Posts: 5,255

Re: Accessing Excel file from server and generate the same as an output to the stored process.

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
Solution
‎08-31-2016 05:56 AM
Frequent Contributor
Posts: 91

Re: Accessing Excel file from server and generate the same as an output to the stored process.

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

Contributor
Posts: 36

Re: Accessing Excel file from server and generate the same as an output to the stored process.

Hi Boemskats,

 

Thank you, 

Greatly appreciate it.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

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