Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Exporting a txt file with line record length greater than 32767 characters?

Tags:

file

sas

I have been trying to export a SAS data set with 49 variables. Each of these variables can potentially be 32767 characters long. I want to write this data set to a txt file, but SAS limits me with the lrecl option at 32767 characters. Is there a way to do this? I tried using the data step.

data _null_;
%let _EFIERR_ = 0; /* set the ERROR detection macro variable */
%let _EFIREC_ = 0;     /* clear export record count macro variable */
file 'C:path\TEST.txt';
if _n_ = 1 then do;
   put "<BLAH>"
   ;
end;
set  WORK.SAS_DATASET   end=EFIEOD;
   format raw1 $32767. ;
   format raw2 $32767. ;

   etc...
 do;
   EFIOUT + 1;
   put raw1 $ @;
   put raw2 $ @;

   etc...
   ;
 end;
if _ERROR_ then call symputx('_EFIERR_',1);  /* set ERROR detection macro variable */
if EFIEOD then
 do;
   put "</BLAH>"
   ;
   call symputx('_EFIREC_',EFIOUT);
 end;
run;
like image 797
Mark Nielsen Avatar asked Apr 09 '14 19:04

Mark Nielsen


1 Answers

Sure. You just need to specify the LRECL yourself.

filename test temp;
data _null_;
set sashelp.class;
file test lrecl=999999;
put
@1 name $32767.
@32768 sex $32767.
@65535 age 8.
;;;;
run;

Some OSs might limit your logical record length, but it's at least 1e6 in Windows so you should be okay.

like image 159
Joe Avatar answered Oct 27 '22 20:10

Joe