BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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!
2 REPLIES 2
deleted_user
Not applicable
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
Cynthia_sas
SAS Super FREQ
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

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 1094 views
  • 0 likes
  • 2 in conversation