Your SAS programs, embedded in web apps and elsewhere

How to directly stream the perl script output to sas _webout?

Reply
N/A
Posts: 0

How to directly stream the perl script output to sas _webout?

Hello, I want to supply a excel output for users to download. What I do now in my sas program is using sas to create csv file, then call a perl script to convert this csv file to binary excel file, finally using a data step to read the excel file generated by perl and output to the fileref _webout as follows. It works fine.

%ds2csv(data=export,csvfile=export.csv,labels=n);
filename plrun pipe "csv2xls -o tmp.xls export.csv";
%let rv=%sysfunc(appsrv_header(Content-type,application/vnd.ms-excel));

data _null_;
infile plrun;
input;
put _infile_;
run;

data _null_;
file _webout recfm=n;
infile "tmp.xls" recfm=n;
input byte $char1. @@;
put byte $char1. @@;
run;

I want to if there are some methods to stream the perl output directly to _webout fileref? I tried let my perl script output to standard output, then using filename to pipe the output to sas as input as follows.

%ds2csv(data=export,csvfile=export.csv,labels=n);
filename plrun pipe "csv2xls -o - export.csv";
%let rv=%sysfunc(appsrv_header(Content-type,application/vnd.ms-excel));

data _null_;
file _webout recfm=n;
infile plrun;
input byte $char1. @@;
put byte $char1. @@;
run;

But it give an wrong output which excel can not read. Are there some options or other method to make it works? Thanks in advance!
N/A
Posts: 0

How to stream the output of perl script to _webout directly?

Posted in reply to deleted_user
Sorry for repost. when I post the broswer gives a error and let me back to edit again. so I back an post again.
Admin may please help to delete the duplicated posts. Thanks. Message was edited by: cxterm
SAS Super FREQ
Posts: 8,864

Re: How to directly stream the perl script output to sas _webout?

Posted in reply to deleted_user
Hi:
Context is everything. I'm not sure how you're using a Perl script....whether you're really talking about stored processes or??? SAS/IntrNet?? SAS Integration Technologies???

First of all, if you are running on the BI platform, I'm not sure I understand why you're making a CSV file, then creating an Excel file from the CSV file??? If you were using the Platform, your task or results or data set could come directly to Excel via the SAS Add-In to Microsoft Office.

Since I see a call to APPSRV_HEADER, I suspect you're using SAS/IntrNet and a PERL script in your HTML/web front end????

Generally speaking _webout is a reserved fileref. When you use RUNMODE=S, you are supposed to be using SAS/IntrNet Application Dispatcher or a Stored Process Server. It is possible that the documentation on the use of this macro will help you:
http://support.sas.com/documentation/cdl/en/lrdict/61724/HTML/default/a002683390.htm

Otherwise, your best bet for help is to work with Tech Support, as there would be different solutions to your question depending on the context and method by which your code is executing.

cynthia
Ask a Question
Discussion stats
  • 2 replies
  • 248 views
  • 0 likes
  • 2 in conversation