Dear Experts,
I encountered this error from running this code:
ERROR: The text expression length (65572) exceeds maximum length (65534). The text expression has
been truncated to 65534 characters.
proc sql;
select catx("=", NAME, quote(trim(dscr)))
into :label_list separated by " "
from test;
quit;
Is there a way to solve this error?
Please let me know.
Many thanks in advance.
Hello,
What are you creating this macrovariables list for ?
Macro language is not meant to be used to manipulate data.
So the solution would be not to create this list of macrovariables and
use bases SAS language to achieve your goal.
@ari wrote:
Is there a way to solve this error?
Yes. Stop abusing macro variables for things they are not meant for.
DATA belongs in DATASETS.
You can always use your above select as a sub-select in SQL, load a hash object in a data step from it, or create a format. Or do a join, which will scale up until you run out of disk storage.
Sounds like you are trying to generate a list of variable labels, to use in another program, e.g.:
Data want;
set have;
label &label_list;
run;
I would consider writing the code to a temporary file instead:
filename tempsas temp;
Data _null_;
file tempsas;
put 'label';
do _N_=1 to nobs;
set test nobs=nobs;
dscr=quote(trim(dscr),"'");
put name '=' dscr;
end;
put ';';
end;
data want;
set have;
%include tempsas;
run;
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.