Peter;
I know where you are going with this I think. Something to ponder the next time I have to do this more efficiently.
In the interim, I simply parsed out a subset, ran a macro, and re-merged later.
For all though, I do appreciate all the tips.
Best
Lawrence
%macro group_roles (data=, var=);
proc sort data=&data(keep=&var) out=values nodupkey;
by &var;
run;
data _null_;
set values end=last;
call symputx('GROUP'||left(_n_),&var);
if last then call symputx('count',_n_, 'g');
run;
%put _local_;
DATA _NULL_ ;
select(&var);
%do i=1 %to &count;
DATA GROUP&i;
SET PREP_ROLES;
where role2="&&GROUP&i";
IF SUBSTR(COMPLIANCE,1,1)='1' THEN &&GROUP&i.._YES=1;
IF SUBSTR(COMPLIANCE,1,1)='2' THEN &&GROUP&i.._NO=1;
run;
%END;
%mend group_roles;
%group_roles(data=roles, var=role2);
... View more