I've previously written about how to generate a sequence of evenly spaced points in an interval. Evenly spaced data is useful for scoring a regression model on an interval.

In the previous articles the endpoints of the interval were hard-coded. However, it is common to want to evaluate a function in the interval [min(x), max{x}], where x is an observed variable in data set. That is easily done in the DATA step by first running a PROC SQL call that puts the minimum and maximum values into macro variables. The macro variables can then be used to generate the evenly spaced values. For example, the following statements generate 101 points within the range of the Weight variable in the Sashelp.Cars data set:

```/* Put min and max into macro variables */ proc sql noprint; select min(Weight), max(Weight) into :min_x, :max_x from Sashelp.Cars; quit;   /* Create data set of evenly spaced points */ data ScoreX; do Weight = &min_x to &max_x by (&max_x-&min_x) / 100; /* min(X) to max(X) */ output; end;```

See the article "Techniques for scoring a regression model in SAS" for various SAS procedures and statements that can score a regression model on the points in the ScoreX data set.

You can also use this technique to compute four macro variables to use in generating a uniformly spaced grid of values.

If you are doing the computation in the SAS/IML language, no macro variables are required because you can easily compute the minimum and maximum values as part of the program:

```proc iml; use Sashelp.Cars; read all var "Weight" into x; close; w = do(min(x), max(x), (max(x)-min(x))/100); /* min(X) to max(X) */```
Share