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. In this case 'Log_flag' should be set to 0, but the program runs as if it were a 1. 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; %if &log_flag. = 1 %then %do; xxx; %end;
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. Also, when I set the "test" variable to the value of symget("log_flag"), the test variable appears in the dataset with the correct value (0 in this case). The if/then statement just seems to always evaluate to true and I have no idea why. Please let me know if there is any other information you need to help me figure this out. Thanks guys!
... View more