In SAS 9 data step, even with the varchar() type, there are restrictions on the size of a variable that can be processed.

This can create coding challenges when writing long values to a text file.

Fortunately with direct macro processing, large variables (up to approx 65k) can be written directly from macro variables into text files using an approach like the following:

%let filrf=somefile;
%let rc=%sysfunc(filename(filrf, 
   %sysfunc(pathname(work))/test2.txt));
%let fid=%sysfunc(fopen(&filrf,o,0,P));
%let a=%sysfunc(repeat(A,65000));

%let rc=%sysfunc(fput(&fid,&a));
%let rc=%sysfunc(fwrite(&fid));
%let rc=%sysfunc(fclose(&fid));