03-29-2012 06:53 AM
proc sql ;
select distinct(email_id) into: mail separated by ',' from temp;
Nothing wrong with above code but still i am getting error due to macro variable length..
ERROR: The length of the value of the macro variable email_id (65956) exceeds the maximum length (65534). The value has been truncated to 65534 characters.
How resolve this..???
Thanks in advance..
03-29-2012 07:24 AM
IMHO, There is nothing you could do on the length alone. You probably have to somehow subset your data and use more than one macro variable.
03-29-2012 09:41 AM
Just write the code to a file.
filename email temp;
set temp end=eof ;
if _n_=1 then put 'filename email from="xxxxxxxx" to="' mail ;
else put ',' mail @;
if eof then put '";' ;
03-29-2012 11:17 AM
Sorry TOM, i did't get you.
insted of writing all the mail id's in "to=" option ,i am storing all the mail id's in a silgle macro variable and i am puting that variable in to= option.
03-29-2012 11:59 AM
But you said that you have too many addresses to put into a macro variable.
So instead of storing them in a macro variable store them in a file.
Test if the FILENAME statement has the same limit.
You are probably better off reading the documentation that DATA _NULL_ points you to so that you can figure out how to generate the TO addresses from your data.
03-29-2012 12:13 PM
See this little tidbit from SAS posted recently. I haven't had a chance to test it out, so let me know if it works.
%let dsid=%sysfunc(open(&dsn(where=(key > 0))));
%do i = 1 %to &cnt;
%if &i ne &cnt %then %do;
03-29-2012 10:47 PM
For your situation, I usually try to use two ways.
1. Use a single macro variable to store a single e-mail.
proc sql ;
select distinct(email_id) into: mail1-mail&sqlobs. ;
filename email from="**************@####.com"
%do i=1 %to &sqlobs. ;
%if &i ne &sqlobs %then %do; , %end;
2. Use Call execute ,actually it is the same with Tom's code,but more convenience.
input mail $40. ;
set mail end=last ;
if _n_ eq 1 then call execute(' filename email from="**************@####.com" to=" ' );
call execute ( mail );
if not last then call execute(' , ');
if last then call execute( '............................................' );