Proc reg:并行检查最好的三个变量

Proc reg: checking the best three variables in parallel

我正在使用以下代码开发回归宏:

%Macro Regression;

%let index = 1;

%do %until (%Scan(&Var2,&index," ")=);

%let Ind = %Scan(&Var2,&index," ");

ods output SelectionSummary = SelectionSummary;

proc reg data = Regression2 plots = none;

model &Ind = &var / selection = stepwise maxstep=1;

output out = summary R = RSQUARE;

run;

quit;

%if &index = 1 %then %do;

data final;
set selectionsummary;
run;

%end;

%else %do;

data final;
set final selectionsummary;
run;

%end;

%let index = %eval(&Index + 1);

%end;

%mend;

%Regression;

这段代码有效并给了我一个 table 它突出显示了解释因变量最多变化的自变量。

我正在寻找一种方法 运行 这个但是回归给了我三个最好的自变量来解释因变量,如果它被选为第一个变量,例如:

选择的模型:

GDP = Human Capital
GDP = Working Capital
GDP = Growth

DependentVar Ind1          Ind2            Ind3    Rsq1 Rsq2 Rsq3
GDP          human capital working capital growth  0.76 0.75 0.69

DependentVar Independent1    Rsq
GDP          human capital   0.76
GDP          working capital 0.75
GDP          growth          0.69

编辑:

如果有办法让stepwise maxstep = 3,并且在第一个自变量唯一的条件下,每个因变量都有最好的三个自变量组合,那将是绝对的奖励。

TIA。

在您的模型语句中尝试 STOP=3 选项。它将拟合最多包含三个变量的最佳模型。但是,它不适用于逐步选项,但适用于 R^squared 选项。

model &Ind = &var / selection = maxR stop=3;

如果您只想考虑 3 个变量模型,也包括 start=3。

model &Ind = &var / selection = maxR stop=3 start=3;