Search notes:

SAS macro: writeToFile

%tq84_writeToFile is a simple macro that writes a single line of text to a named file. It seems to be rather slow, though.
%tq84_writeToFile(&filename, &text_line)

writeToFile.sas

%macro tq84_writeToFile_M;
   data _null_;
      file &filename mod;
      put  &txt;
   run;
%mend  tq84_writeToFile_M;


proc fcmp outlib=work.funcs.tq84;
  subroutine tq84_writeToFile_F(fileName$, txt$);
    rc = run_macro('tq84_writeToFile_M', fileName, txt);
  endsub;
run;

options cmplib=work.funcs;

%macro tq84_writeToFile(fileName, txt);
  %sysfunc(tq84_writeToFile_F(&fileName, &txt));
%mend  tq84_writeToFile;
Github repository about-SAS, path: /macros/writeToFile.sas

Test

%macro writeToFileTest;
  
   %do i = 1 %to 100;
   %do j = 1 %to &i;
       %tq84_writeToFile(%sysget(HOME)/writeToFileTest/&i..txt, &j)
   %end; %end;

%mend writeToFileTest;

%writeToFileTest;
Github repository about-SAS, path: /macros/tests/writeToFile.sas

See also

macros

Index