BookmarkSubscribeRSS Feed
bheinsius
Lapis Lazuli | Level 10

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

6 REPLIES 6
TomKari
Onyx | Level 15

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

bheinsius
Lapis Lazuli | Level 10

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.

ballardw
Super User

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.

bheinsius
Lapis Lazuli | Level 10

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

bheinsius
Lapis Lazuli | Level 10

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.

bheinsius
Lapis Lazuli | Level 10

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;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

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
  • 6 replies
  • 1922 views
  • 2 likes
  • 3 in conversation