Good day,
I assume you have only a single condition in the table? (Same reason every row.) Unless, you need to select the proper reason via other reasons. This takes the reason in the last row.
Firtst lets generate some dummmy data.
data T1;
infile datalines delimiter=',';
input cond $21. Income age ;
cards;
"If Income>=10000" , 1000 , 10
"If Income>=10000" , 10000 , 100
"If Income>=10000" , 100000 , 1000
;run;
What we do here is create Global variable &condition into which we put the last value of Cond-column. You can also use proc sql to easily select desired string into the variable. See more on proc sql Into here
data _NULL_;
set T1;
CALL SYMPUT("Condition", Cond);
run;
Here we begin with set T1 and apply the String &condition, which contains the rule. I needed to remove the quotes from the command in order to get SAS to perform the function. It is a bit unconventional to apply command this way but works.
data T2;
set T1;
%qsysfunc(dequote(&Condition.));
run;
EDIT: Based on further elaboration the following has been tested to work. One feeds the conditions to macro loop, which selects the condition. If there are dupilates, I suggest you split conditions and data to different sets.
%macro Create_subset(Row);
data _NULL_;
set T1(firstobs=&row obs=&row.);
CALL SYMPUT("Condition", Cond);
run;
data Subset_&row.;
set T1;
%qsysfunc(dequote(&Condition.));
applied_cond = &Condition.;
run;
%mend Create_subset;
data _NULL_;
set T1;
call execute('%nrstr(%Create_subset('||strip(_N_)|| '))');
run;