05-28-2015 08:15 PM
I'm trying to send out ID's of 2 SAS datasets which has ID's that were transferred and ID's that failed to transfer in an email body as text but not able to get the format right. I just need plain text as html is getting stuck and slow. Here is my current code but the ID's are missing after it reaches 32000.. I saw CATX takes only that but also when it is called through Macro it can take 64000 but since I'm new to SAS I'm not sure how to do it.
Please help and also let me know how to add the SAS dataset of ID's that were not processed after the text of ID's processed.
filename mymail email "&emaillist"
subject = "&env. Records Transferred on %sysfunc(date(), yymmdd10.)";
length id_list $ 3000;
retain id_list '';
set workgo.recds_processed nobs = nobs end = eof;
if _n_ = 1 then do;
put 'Number of records processed=' nobs;
put 'The IDs are:';
/* Print the IDs in chunks */
if length(strip(id_list)) > 2000 then do;
call catx(', ', id_list, id);
if eof then put id_list;
09-23-2015 06:49 PM
Something like this should work. It was unclear from your example what filtering criteria should be used for good IDs (that transferred) and bad IDs (that did not transfer), so this example is generic.
PROC SQL; SELECT DISTINCT id INTO :good_id_list SEPARATED BY ", " FROM work.my_dataset1 WHERE /* add filtering criteria for IDs that are good (transferred) */ ; QUIT; PROC SQL; SELECT DISTINCT id INTO :bad_id_list SEPARATED BY ", " FROM work.my_dataset2 WHERE /* add filtering criteria for IDs that are bad (did not transfer) */ ; QUIT; DATA _null_; file sendit email from="your_name@name_of_company.com" to=("recipient_name@name_of_company.com") cc=("courtesy_copy_name1@name_of_company.com" "courtesy_copy_name2@name_of_company.com" "courtesy_copy_name3@name_of_company.com") subject="&env. Records Transferred on %sysfunc(date(), yymmdd10.)" importance="High"; if length(&bad_id_list) > 65500 then do; put "BEWARE: macro variable 'bad_id_list' exceeds maximum length of 64 kilobytes."; put "The list of IDs have been truncated."; end; if length(&good_id_list) > 65500 then do; put "BEWARE: macro variable 'good_id_list' exceeds maximum length of 64 kilobytes"; put "The list of IDs have been truncated."; end; put "Below is a list of IDs that transfered:"; put "======================================="; put &good_id_list; put ""; put ""; put "Below is a list of IDs that did not transfer:"; put "============================================="; put &bad_id_list; put ""; put ""; put "Regards,"; put "SAS guy"; put; RUN;