09-18-2017 05:08 PM
Here I have the dataset and code like the following,
and since there is only 4 datapoints of x, the output table will contain only 4 prediced value of y.
What I want is the predicted values of y when x varies from 1 to 40, is that possible to generate the table in SAS? I know it's convenient to use the regression model to generate the results in EXCEL ,but I wonder if it's ok that I complete all of the steps in SAS.
data a; input x y; cards; 1 0.992010835 2 0.966176685 3 0.955358056 4 0.941511026 ; run; proc glm data= a; model y= x; output out= outa p=predy r=resid; run;
09-18-2017 05:12 PM
Even if you were to make such predictions, they would never in any way be considered statistically valid. If X ranges from 1 to 4 in your modeling data set, you can only make predictions for X in the range of 1 to 4.
09-18-2017 05:20 PM
Not that your sample is likely good enough but use this input data set and look at the output data set.
data a; input x y; cards; 1 0.992010835 2 0.966176685 3 0.955358056 4 0.941511026 5 . 6 . 7 . 8 . 9 . 10 . 11 . 12 . 13 . 14 . 15 . 16 . 17 . 18 . 19 . 20 . 21 . 22 . 23 . 24 . 25 . 26 . 27 . 28 . 29 . 30 . 31 . 32 . 33 . 34 . 35 . 36 . 37 . 38 . 39 . 40 . ; run;
And place a QUIT; at the end of your Proc Glm;
09-18-2017 05:32 PM
The term you're looking for is 'score' a model.
You can do this several ways in SAS, partly depending on the PROC.
See the methods illustrated here.
As others have commented give your sample this isn't appropriate but I'm going to assume it was a mock up. At the end of the data, the validity is up to you.
09-18-2017 06:32 PM
A crude but simple method is with the CODE statement :
filename t temp; proc glm data= a; model y= x; code file=t; run; quit; data b; do x = 1 to 40; %include t; output; end; run;
09-18-2017 08:49 PM
With only one predictor below data step can be used for the predicted values.
do X=1 to 40;
predy=1.004343665 - 0.016231806*X;