Your SAS programs, embedded in web apps and elsewhere

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

Reply
N/A
Posts: 0

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

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!
Ask a Question
Discussion stats
  • 0 replies
  • 166 views
  • 0 likes
  • 1 in conversation