SAS - สร้างตัวแปรจำลองสำหรับตัวแปรทั้งหมด

data test;
   input id v1 $ v2 $ v3 $ ;
   datalines;
1 A A A
2 B B B
3 C C C
4 A B C
5 B A A
6 C B A
;

proc glmselect data=test outdesign(fullmodel)=test_design noprint ;
   class v1 -- v3;
   model id = v1 -- v3 /selection=none noint;
run;
/*Run model within PROC GLMMOD for it to create design matrix
Include all variables that might be in the model*/
proc glmmod data=sashelp.class outdesign=want outparm=p;
    class sex age;
    model weight=sex age height;
run;

/*Create rename statement automatically
THIS WILL NOT WORK IF YOUR VARIABLE NAMES WILL END UP OVER 32 CHARS*/
data p;
    set p;

    if _n_=1 and effname='Intercept' then
        var='Col1=Intercept';
    else
        var=catt("Col", _colnum_, "=", catx("_", effname, vvaluex(effname)));
run;

proc sql ;
    select var into :rename_list separated by " " from p;
quit;

/*Rename variables*/
proc datasets library=work nodetails nolist;
    modify want;
    rename &rename_list;
    run;
quit;

proc print data=want;
run;