0

I need to get a dataset of a uniform grid 20x20 using info from SASHELP.CARS so that x and y variables are obtained as follows:

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;

Weight and HorsePower are variables of SASHELP.CARS. Furthermore the grid dataset has to have two more columns EnginSizeMean LengthMean with the same value in each row that equals mean(EnginSize) and mean(Length) from SASHELP.CARS (need all this to build dependency graph for regression model).

adeline
  • 21
  • 4

1 Answers1

1

First calculate the statistics you need to use.

proc summary data=sashelp.cars ;
  var weight horsepower enginesize length ;
  output out=stats
    min(weight horsepower)=
    max(weight horsepower)=
    mean(enginesize length)=
    / autoname
  ;
run;

Then use those values to generate your "grid".

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;
Tom
  • 47,574
  • 2
  • 16
  • 29