Brilliant! Thank you*840 to Astounding. So putting it all together we have the following. Perhaps there is a more efficient program, but I am happy with this. * create a new variable identifying the unique strata;
data all_combinations;
do a=1 to 2;
do b=1 to 12;
do c=1 to 5;
do d=1 to 7;
single_variable = d + 10*c + 100*b + 10000 * a;
output;
end; end; end; end;
run;
* now merge that back to the main dataset (test1);
proc sort data=test1;
by a b c d;
run;
proc sort data=all_combinations;
by a b c d;
run;
data merge1;
merge test1 all_combinations;
by a b c d;
run;
* create the dummy codes by strata for the variables (ms3c and edu2c);
data test2 (keep= single_variable ms2 ms3 edu2);
set merge1;
if ms3c=2 then ms2=1; else ms2=0;
if ms3c=3 then ms3=1; else ms3=0;
if edu2c=2 then edu2=1; else edu2=0;
run;
* now create a dummy code matrix table for each unique strata (840) and name the tables with the strata id code (single_variable);
data _null_;
call execute('proc sql') ;
do until (done);
set test2 end=done;
dsname = put(single_variable, z5.);
call execute('create table xmat_' || dsname || ' as select * from test4 where single_variable= ' || dsname || ';' ) ;
end;
call execute('quit;' ) ;
stop;
run;
... View more