The following DATA Step is part of a SAS macro. There are two conditions that should be checked when reading the data set return_check. If the first or second conditions are met, then a macro variable "Data_status" should take the string value 'Exclude'. If neither conditions are met then the macro variable "Data_status" should take the string value 'Include'. When I run the DATA Step the first condition is met. This is evident as the variable "Status" in the data set check2 has the string value "Exclude". However, and here come what is puzzling me, after the DATA Step, the macro variable Data_status resolves to "Include". I am not sure what is it that I am doing wrong. Any help will be highly appreciated.
%macro analysis;
----------codes not shown--------
proc means data=temp noprint; *A prior step that produces the input dataset return_check;
var ret;
by event_id ab_:;
output out=return_check nmiss=missing_ret;
run;
data check2;
set return_check;
if Ab_M2=Ab_m1=ab_0=Ab_1=Ab_2=0 and missing_ret>(_FREQ_-50) then do; *Condition 1;
call symput('Data_status','Exclude');
Status=symget("Data_status");
end;
else if ab_M1=1 and ab_0=1 and ab_1=1 and missing_ret=1 then do; *Condition 2;
call symput('Data_status','Exclude');
Status=symget("Data_status");
end;
else do;
call symput('Data_status','Include');
Status=symget("Data_status");
end;
run;
%put &Data_status;
%if &Data_status eq %bquote(Exclude) %then %do;
%mend analysis;
----------codes not shown--------
Here is a copy of the input Data set "return_check"
Ab_M2 Ab_M1 Ab_0 Ab_1 Ab_2 _TYPE_ _FREQ_ missing_ret
0 0 0 0 0 0 100 100
0 0 0 0 1 0 1 1
0 0 0 1 0 0 1 1
0 0 1 0 0 0 1 1
0 1 0 0 0 0 1 1
1 0 0 0 0 0 1 1
Thanks for your time in advance