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
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
> 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.
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.
thanks but the %qcmpres is only applied to the filename, not to the text written to _webout..
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.
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;
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.