使用来自另一个数据集的信息在SAS中创建网格数据

使用来自另一个数据集的信息在SAS中创建网格数据,sas,grid,dataset,datastep,Sas,Grid,Dataset,Datastep,我需要使用SASHELP.CARS中的信息获取一个统一网格20x20的数据集,以便获得x和y变量,如下所示: do y = min(weight) to max(weight) by (min(weight)+max(weight))/20; do x = min(horsepower) to max(horsepower) by (min(horsepower)+max(horsepower))/20; output; end; end; 重量和马力是

我需要使用
SASHELP.CARS
中的信息获取一个统一网格20x20的数据集,以便获得
x
y
变量,如下所示:

do y = min(weight) to max(weight) by  (min(weight)+max(weight))/20;
    do x =  min(horsepower) to max(horsepower)  by (min(horsepower)+max(horsepower))/20; 
        output;
    end;
end;

重量
马力
SASHELP.CARS
的变量。此外,网格数据集还必须有两列
enginesizemean lengthemean
,每行中的值相同,分别等于
SASHELP.CARS中的
mean(enginesize)
mean(Length)
(需要所有这些来为回归模型构建依赖关系图).

首先计算需要使用的统计数据

proc summary data=sashelp.cars ;
  var weight horsepower enginesize length ;
  output out=stats
    min(weight horsepower)=
    max(weight horsepower)=
    mean(enginesize length)=
    / autoname
  ;
run;
然后使用这些值生成“网格”

data want;
  set stats;
  do y = 1 to 20 ;
    weight= weight_min + (y-1)*(weight_min+weight_max)/20;
    do x =  1 to 20 ;
      horsepower  =  horsepower_min + (x-1)*(horsepower_min+horsepower_max)/20;
      output;
    end;
  end;
run;