I'd like to create multiple flags in my dataset (and many derived numeric characteristics), but I am struggling to get the code to work.
I am using an iterative loop with conditions. Any help or suggestions on resolutions would be greatly appreciated.
Here is the code I tried, which creates a flag, but this is not then a variable in my new dataset.
%macro gb1(howmany);
%do i=1 %to &howmany;
%if status&i = 1 %then %let &gb1_&i = 1;
%else %if status&i = 2 %then %let &gb1_&i = 1;
%else %if dpd&i >= 2 %then %let &gb1_&i = 1;
%else %if ((dpd&i < 2) and (dpd&i >= 1)) %then %let &gb1_&i = 2;
%else %let &gb1_&i = 1;
%end;
%mend gb1;
data test;
set y2014.perf_data_derive (where=((dpd15 <= 2) and (prod = 1)));;
%gb1(36);
run;
I appreciate any help I can get, thanks in advance.