I'm having trouble getting If/Then statements to work correctly with my macro variables inside a datastep. I'm writing a macro to handle two different cases: calculating stat tests with no transformation, and then calculating stat tests after a natural log transformation. If my data fails the test of normality, I log transform and test again. If it passes, I set my global flag, log_flag
, to 1. I then want to test the status of this flag in data steps in order to correctly handle the transformed (or not) variables. I've tried variations of the following:
Data want;
set have;
if symget("log_flag")=1 then do;
if &log_flag. = 1 then do;
if resolve("log_flag")=1 then do;
test=symget("log_flag");
if test=1 then do;
end
No matter what I try, the if/then statement is essentially ignored and all code following it is processed as if the if/then were true, even when it is false. I know that the log_flag
is being correctly assigned a value of zero because the %if
%then
statements work and execute correctly in open code. I'm just having trouble getting it to resolve correctly inside a datastep.
Please let me know if there is any other information you need to help me figure this out. Thanks guys!