Hi All,
I'm facing a hurdle with SAS reading long lines of code. Is there any way that I can increase the maximum number of permitted characters in lines of code?
I'm getting an abort message saying 6000 is the maximum number.
Can someone please help me on this?
Thank you
Reading long lines of data is easy for SAS. In fact, the usual default for maximum line length is 32,767 characters. So I'm not certain how you are encountering this 6,000 character limit.
The tool for controlling how many characters can be read is LRECL. For example:
infile somedata lrecl=8000;
Perhaps you need to add the PAD option:
infile somedata lrecl=8000 pad;
That way, SAS will pad with blanbks any lines that are shorter than 8000 characters.
Or perhaps this is not the problem you are asking about?
Thank you Astounding.
But your comment doesn't address the issue I'm facing.
I have several %let = statements in my SAS program.
Many of these statements extend beyond column 6000 in the editor.
The reason why my %let = statements are so long is because they list a large number of values, and I'm trying to fit the values into a temporary array.
See the following example:
%let number_2_max = 1514 ; This means the dimension of my array will end up being 1514 values, and each value happens to have up to 5 decimal places.
The next code statement is the following:
%let IRT_A_2_max = listing of 1514 values here ; This has a listing of all 1514 values. This statement extends to column 13050 in the editor.
The next section of code is a data step. The data step has an array statement with macro variables to read in the dimension of the array (i.e., &number_2_max) and the list of values included in the array (i.e., &IRT_A_2_max) .
data want;
array IRT_A_p_2_max (&number_2_max) _temporary_ (&IRT_A_2_max);
do i=1 to dim(IRT_A_p_2_max);
putlog IRT_A_p_2_max(i)= ;
end;
run;
When I try to run my code SAS aborts and explains that I have lines of code that exceed more than 6000 characters.
Is there some way I can get around this issue?
Thanks
So you are encountering an issue that a single line in a SAS programs has size limitations. I doubt you can control that, although perhaps someone wiser than myself will come along. In the meantime, consider ...
Somewhere, somebody has to come up with those 1514 values. Why not put them in a DATA set instead of a macro variable? If you really need the array, you can get the values from a data set into an array. For example, suppose you have a data set named all1514values, containing a variable named variable_name_from_all1514values:
data want;
array num1514 {1514} _temporary_;
if _n_=1 then do i=1 by 1 until (done);
set all1514values end=done;
num1514{i} = variable_name_from_all1514values;
end;
set have;
**** then process from the array as needed;
run;
Below code runs on my laptop without errors or warnings (9.4M7, Windows). What about yours?
%let number_2_max=1514;
data _null_;
length IRT_A_2_max $32767;
do i=1 to &number_2_max;
IRT_A_2_max=catx(' ',IRT_A_2_max, put(rand('uniform',0,1000),f10.5));
end;
call symputx('IRT_A_2_max',IRT_A_2_max);
run;
data want;
array IRT_A_p_2_max (&number_2_max) _temporary_ (&IRT_A_2_max);
do i=1 to dim(IRT_A_p_2_max);
putlog IRT_A_p_2_max(i)=;
end;
run;
Why are you using a %let statement in the first place. That much data belongs in a data set and place, if really needed, the values into a macro variable with a tool like proc sql.
Large numbers of data values should be stored in data files, not in programs. They can be handled way more efficiently that way. If you explained what you are trying to do with these long macro variables I'm sure there is a better way to approach this.
There is no reason to make the lines of code very long to store 5 digit numbers!
Just put in some line breaks!!!
Example:
%let number_2_max = 6 ;
%let IRT_A_2_max =
12345 67890
23456 78901
34567 89012
;
data want;
array irt [&numer_2_max] _temporary_ (&irt_a_2_max);
...
But seriously put the list into a FILE and read the file into DATA and skip the macro variables completely.
@TacoLover wrote:
Hi All,
I'm facing a hurdle with SAS reading long lines of code. Is there any way that I can increase the maximum number of permitted characters in lines of code?
I'm getting an abort message saying 6000 is the maximum number.
Can someone please help me on this?
Thank you
Huh? Why the heck would you have lines of code with over 6,000 characters?
If fact you should not have lines of code with more than 75 characters. More than that and it is hard for humans to read.
I do not have any trouble using lines of code with more than 6000 characters.
Try this program:
filename code temp;
data _null_;
file code ;
put 'data _null_; set sashelp.class;' @6500 'run;' ;
run;
data _null_;
infile code;
input;
list;
run;
%include code / source2;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.