03-30-2015 06:42 PM
For the code below, if "error" variable in the following work.merge dataset loaded into hash table has values that contain many special characters like [,./;'etc]. How do I make the following code works? (please just focus on error variable which is highlighted in blue, that is where I get the error in the log)
FILENAME Mailbox EMAIL "&email"
PUT "Error message: &error";
PUT "Run time: &time";
PUT "Abortcode: &abortcode";
length email $200 suite $200 reference $200 errormsg $200 time $200 abortcode $200;
if _n_=1 then do;
declare hash myhash(dataset: 'work.merge',ordered:'a'); /* sort order is ascending */
declare hiter iter('myhash');
myhash.definekey('suite'); /* define a key */
myhash.definedata('Email','Suite','Reference','errormsg','time','abortcode'); /* getting the columns */
myhash.definedone(); /* finish the definitions */
call missing(email, suite,reference,errormsg,time,abortcode); /* avoid uninitialized variable notes (miss in the dataset not in hash)*/
/* Iterate through the hash object and output data values */
rc = iter.first();
do while (rc = 0);
call execute('%Email(email='||Email||',suite='||Suite||',reference='||Reference||',error='||errormsg||',time='||time||',abortcode='||abortcode||')' );
rc = iter.next();
03-30-2015 07:42 PM
Why not use the data step to send the email instead of calling a macro? That would eliminate the need to worry about macro quoting.
03-30-2015 07:50 PM
There are thousands record in SAS table each contains different email address.
I want to use hash iterator to read each email record in the table and execute the email macro to send out the email to their corresponding users.
03-30-2015 07:56 PM
Did you read the page I linked to?
You can use conditional logic in the DATA step to send multiple messages and to control which recipients receive which message. For example, suppose you want to send customized reports to members of two different departments. Here is a DATA step example: