Hi.
Apologies first for a long post.
I am calling a macro from a dataset which contains the locations of several SAS logs.
Once the log has been checked I create a macro variable which I want included in the subject field of an email which is created within the macro program.
My problem is that the macro variable I created is not available when the code is executed, but I don't understand why.
Here is a rough representation of my code:
Having spent some time looking into this I gather that the macro program is stored in a macro catalogue until a call to it is made. At which point the program is placed back into the Input Stack and tokenised as normal. I appreciate that this is a simplification and I may also be wrong.
This is where my 'understanding' fails.
I think that the first data step should have been compiled and executed before the second, and as such the macro variable 'rc_level' should be available for the 'filename' statement to resolve. But the log suggests that this is not the case as I get the appropriate 'WARNING: Apparent symbolic reference RC_LEVEL not resolved' message.
I have managed to get this process to work (after a fashion), but more by hacking than design. Here is the code for that (changes in red):
This does get me the results I want but again with the 'WARNING: Apparent symbolic reference RC_LEVEL not resolved' in the log.
Can anyone help me understand this?
Thanks for your patience and time.
Kind regards,
Asender
Apologies first for a long post.
I am calling a macro from a dataset which contains the locations of several SAS logs.
Once the log has been checked I create a macro variable which I want included in the subject field of an email which is created within the macro program.
My problem is that the macro variable I created is not available when the code is executed, but I don't understand why.
Here is a rough representation of my code:
Code:
%macro my_macro;
data _null_;
set test;
call symput('rc_level',var1);
run;
filename eout email
To = "email_address"
Subject = "Job has completed with &rc_level."
Attach = ("log summary");
data _null_;
file eout;
put 'LOG Summary attached';
put ' ';
run;
filename eout clear;
%mend my_macro;
*** This DS contains several observations;
data _null_;
set log_list;
call execute('%my_macro');
run;
Having spent some time looking into this I gather that the macro program is stored in a macro catalogue until a call to it is made. At which point the program is placed back into the Input Stack and tokenised as normal. I appreciate that this is a simplification and I may also be wrong.
This is where my 'understanding' fails.
I think that the first data step should have been compiled and executed before the second, and as such the macro variable 'rc_level' should be available for the 'filename' statement to resolve. But the log suggests that this is not the case as I get the appropriate 'WARNING: Apparent symbolic reference RC_LEVEL not resolved' message.
I have managed to get this process to work (after a fashion), but more by hacking than design. Here is the code for that (changes in red):
Code:
%macro my_macro;
[COLOR=red]%symdel rc_level;[/color red]
data _null_;
set test;
call symput('rc_level',var1);
run;
filename eout email
To = "email_address"
Subject = "Job has completed with [COLOR=red]&&[/color red]&rc_level."
Attach = ("log summary");
data _null_;
file eout;
put 'LOG Summary attached';
put ' ';
run;
filename eout clear;
%mend my_macro;
*** This DS contains several observations;
data _null_;
set log_list;
call execute('%my_macro');
run;
This does get me the results I want but again with the 'WARNING: Apparent symbolic reference RC_LEVEL not resolved' in the log.
Can anyone help me understand this?
Thanks for your patience and time.
Kind regards,
Asender