简体   繁体   English

SAS:自动将变量从proc reg传递到proc得分

[英]SAS: Automatically pass variables from proc reg to proc score

I am running multiple interations of sequence containing proc reg and proc score. 我正在运行包含proc reg和proc得分的序列的多个交互。 How do I automatically pass predictors from proc reg to var list in proc score? 如何自动将proc评分中的预测变量从proc reg传递到var list? I know in proc reg, outest outputs a dataset that contains all the variables with predictors being populated with estimates. 我知道在proc reg中,outest输出的数据集包含所有变量,并且预测变量填充有估计。 In that dataset, non predictors have a missing value. 在该数据集中,非预测变量具有缺失值。 Does proc reg allows for an easy way to capture just the predictor variables? proc reg是否允许仅捕获预测变量的简单方法?

Thanks! 谢谢!

One way to go about this would be to use macro variables. 一种解决方法是使用宏变量。

%let varlist = x1 x2 x3 x4;

proc reg data = somedata outest = out;
    model y = &varlist;
run;
quit;

data _null_;
    length newvars $ 2000;
    set out;
    array v{*} &varlist;
    do i = 1 to dim(v);
        if v[i] ne . then newvars = catx(" ", newvars, vname(v[i]));
    end;
    call symputx("newvars", newvars);
run;

%put Predictors=&newvars;

proc score data = somedata;
    var &newvars;
run;

This creates a space delimited list of the predictors from PROC REG and uses that list in the VAR statement in PROC SCORE. 这将从PROC REG创建一个以空格分隔的预测变量列表,并在PROC SCORE的VAR语句中使用该列表。 This approach assumes you have only a single model in your OUTEST dataset. 这种方法假设您的OUTEST数据集中只有一个模型。 But if that is indeed the case, you shouldn't have any missing values for your predictor variables in the OUTEST dataset. 但是,如果确实如此,那么在OUTEST数据集中,您的预测变量不应有任何缺失值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM