DATA Step, Macro, Functions and more

new line

Occasional Contributor
Posts: 7

new line

I run following code.

%macro ptest;
%let filrf=myfile;
%let rc=%sysfunc(filename(filrf,;
%let fid=%sysfunc(fopen(&filrf,a));
%if &fid > 0 %then %do;
%let rc=%sysfunc(fread(&fid));
%let rc=%sysfunc(fput(&fid,This is test data.));
%let rc=%sysfunc(fput(&fid, // mmm mmmm mmm));
%let rc=%sysfunc(fwrite(&fid));
%let rc=%sysfunc(fclose(&fid));

It's work without errors. I recived output file, but in the output file two strings in the one line. I want recive:
This is test data.
mmm mmmm mmm

I need second string start from new line.
Thanks for help.
Frequent Contributor
Frequent Contributor
Posts: 94

Re: new line

Do you perhaps need another fwrite operation between the two fputs?

As I recall, fput adds data to the output buffer, while fwrite submits the record. The fwrite function has a variety of options that allow you to specify the gap between each record (.e.g one line, two lines, etc.) so it might be worth looking up the online help for it.
Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation