BookmarkSubscribeRSS Feed
Linmuxi
Calcite | Level 5

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. 

THank you!!!

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;
  

 

5 REPLIES 5
Astounding
PROC Star

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. 

ballardw
Super User

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;

 

Reeza
Super User

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. 

PGStats
Opal | Level 21

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;
PG
stat_sas
Ammonite | Level 13

Hi,

 

With only one predictor below data step can be used for the predicted values.

 

data want;
do X=1 to 40;
    predy=1.004343665 - 0.016231806*X;
   output;
end;
run;

 

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 3689 views
  • 0 likes
  • 6 in conversation