*First we read in a test data set for you; data mydata; input Y VAR1 VAR2 VAR3; cards; 1 10 33 4 0 20 21 3 1 30 59 2 1 20 76 1 0 30 24 3 0 20 22 2 1 10 28 2 1 10 49 2 0 30 76 2 1 20 59 2 0 30 45 5 0 30 21 4 0 30 49 2 0 10 23 4 1 10 55 2 0 20 29 3 1 10 49 2 0 20 45 5 0 20 24 3 0 10 30 3 0 10 24 5 1 10 59 2 0 30 31 2 0 20 33 4 0 30 22 3 0 30 29 3 0 10 30 3 0 20 28 3 1 30 59 2 0 30 56 2 1 30 77 1 1 20 97 2 0 20 23 4 0 30 25 4 0 30 23 4 0 30 88 1 0 30 49 2 1 30 76 1 1 20 67 1 1 10 55 2 0 20 26 2 1 20 49 2 1 20 68 1 0 30 45 2 1 20 68 1 0 20 32 5 1 30 22 1 1 30 55 2 1 20 66 1 0 20 29 3 ; *Next we estimate a simple logit model and put parameter estimates in sas dataset MYLOGIT; *We use stepwise selection which only selects 2 out of the 3 independent variables; proc logistic data=mydata outest=mylogit descending; model y = var1 var2 var3 /selection=stepwise ; run; *Next we go to MYLOGIT and get extract out variable names of variables found statistically; *significant in the model. We then output them in a SAS dataset for the next step; data mytemp1 (keep=name); length name $32; set mylogit; where _type_="PARMS"; array k{*} _numeric_; do i=1 to dim(k); if k{i} > .z then do; call vname(k{i},name); output; end; end; stop; run; *Now putting those names in a macro for the rest of the program, except we get rid of; *information we do not need like Intercept and _LN_LIKE_. We put them in a file; *called c:\logistic_vars.txt. The macro is called by %variables - contains names of only; *the variables that were statistically significant; data _null_; file "c:\logistic_vars.txt"; set mytemp1 end=last; if _n_=1 then put '%macro' " variables;"; if not(name in ("Intercept","_LNLIKE_")) then put name; if last then put '%mend' " variables;"; run; %include 'c:\logistic_vars.txt'; *Next we estimate a simple logit model using the %variables macro as the independent vars; *Should give us the same estimation results as the first Logit model. This shows the; *dynamic flexibility in the SAS programming language using macros. In other words, you; *didn't have to hardcode the variables VAR1 and VAR3.; proc logistic data=mydata outest=mylogit descending; model y = %variables / ; run;