Your SAS programs, embedded in web apps and elsewhere

stream text file on linux to _webout

Reply
Regular Contributor
Posts: 187

stream text file on linux to _webout

hi,

i have a text file on linux.

i have a stored process that reads the file and streams it to _webout.

the user gets it in his browser as an attachment that opens in notepad.

in notepad, the lines don't end.

the reason is that the line termination string is LF ('0a'x), for notepad it should be CRLF ('0a'x'0d'x).

i tried tranwrd-ing 0a to 0d0a which did not work.

also file _webout termstr=crlf doesn't work.

can anyone tell me what would?

my code:

data _null_;

  rc = stpsrv_header("Content-type","text/plain");

  rc = stpsrv_header("Content-disposition","%str(attachment; filename=saslog.txt)");

run;

data _null_;

  infile "%qcmpres(&job_log_file)";

  input;

  file _webout termstr=crlf;

  put _infile_;

run;

thanks,

Bart

PROC Star
Posts: 1,167

Re: stream text file on linux to _webout

Posted in reply to bheinsius

Because of your "termstr" option, I really think this should work. The only thing I can suggest is to use a hex editor and see what the termination character in your text file is. If it is crlf, SAS is working right and something's wrong with your viewer. If it's lf, I would report it to SAS tech support and see what they say.

Tom

Regular Contributor
Posts: 187

Re: stream text file on linux to _webout

at 18969 - Specifying an encoding for the _WEBOUT fileref does not work when yourun a stored process wi...i read:

> When you run a stored process with the Stored Process Server, any encoding value that you specify for the _WEBOUT fileref will be ignored.

this was fixed but maybe the same applies to the termstr option on _webout.

unless someone posts the solution i will report it to sasts tomorrow.

Super User
Posts: 11,343

Re: stream text file on linux to _webout

Posted in reply to bheinsius

It may be that %qcmpress is removing them, at least from this quicky test code.

 

%let a = a long string that breaks across lines

here is the contination on another line.

There should be a crlf in here somewhere.;

%put %qcmpres(&a);

Which on my system generates:

a long string that breaks across lines here is the contination on another line. There should be a

crlf in here somewhere.

The line break in the output provided by the LOG generator.

Regular Contributor
Posts: 187

Re: stream text file on linux to _webout

thanks but the %qcmpres is only applied to the filename, not to the text written to _webout..

Regular Contributor
Posts: 187

Re: stream text file on linux to _webout

Posted in reply to bheinsius

i reported it to sas techsupp.

in the meantime i fixed it putting in an extra '0d'x:

  data _null_;

    infile "%qcmpres(&job_log_file)";

    input;

    file _webout;

    put _infile_ '0d'x;

  run;

i will post sas techsupp's answer when it arrives.

Regular Contributor
Posts: 187

Re: stream text file on linux to _webout

Posted in reply to bheinsius

sas techsupp thinks that, although not documented, the termstr option is already implicitly applied and cannot be overwritten.

they suggest the following:

  %LET EOL = '0a0d'x;

  DATA _NULL_;

    rc = STPSRV_HEADER('Content-type', 'text/plain');

    rc = STPSRV_HEADER('Content-disposition', 'attachment; filename="saslog.txt"');

    FILE _WEBOUT RECFM=V;

    PUT 'De Sint zat te denken' &EOL;

    PUT 'Wat voor CRLF hij zal schenken' &EOL;

    PUT 'Een Sinterklaasgedicht op rijm' &EOL;

    PUT 'Geschikt voor Windows met een "echte" new line' &EOL;

  RUN;

Ask a Question
Discussion stats
  • 6 replies
  • 808 views
  • 2 likes
  • 3 in conversation