%macro genlong(varname,debug=0); %*--checks length of a global macro variable and generates an assignment statement defining a variable _&varname using concatenation to avoid hitting 4000 byte word limit. The single postional required arg is the name of the macro variable (WITHOUT the &!). So if that arg has the value varnames , then the macro will generate s SAS assignment statement of the form _varnames="...part 1..."||"...part 2..." || ... where the parts are chunks of up to 3000 bytes of the value. This way SAS only sees at most 3000 chars per word and can handle it---; %local s ls lpart nparts startat ; %let s=&&&varname; %let ls=%length(&s); %let nparts=%eval( &ls/3000 +1 ); %let startat=1; %if &debug %then %do; %put s= &s; %put ls= &ls; %put nparts= &nparts; %end; _&varname = %do i=1 %to &nparts; %if &i ne 1 %then %str( || ); %if %eval(&startat + 3000) gt &ls %then %let lpart=%eval(&ls - &startat + 1); %else %let lpart=3000; %if &debug %then %put i= &i startat= &startat lpart= &lpart; %if &i=&nparts %then %do; "%trim(%substr(&s, &startat,&lpart))" %end; %else %do; "%substr(&s, &startat,&lpart)" %end; %let startat=%eval(&startat + 3000); %end; %*--do i loop--; ; %*--to end the assignment statement--; %mend genlong;