BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
inbalia
Calcite | Level 5
DATA data1;
INPUT obs age healthscore cost access$;
DATALINES;
1 37.1744 2.74061 918.92 2
2 56.8510 0.98697 7.29 1
3 62.6610 2.18619 1322.09 1
4 31.3702 3.80720 930613.57 4
5 60.0573 2.12735 972069.19 2
;
RUN;

PROC GLM DATA=data1;
CLASS access;
MODEL cost= healthscore access age/ SOLUTION;
RUN;

DATA data2;
INPUT obs age healthscore access$;
DATALINES;
1 62.6610 2.18619 1
2 60.0573 2.12735 2
3 61.6390 2.06955 1
4 33.8573 4.19116 3
5 47.2659 1.12857 2
;
RUN;

So I have all regression coefficients from data 1, but now I want to get the predicted values (ideally, the sum of predicted values) when I plug in data2 to the pre-existing regression model. I was wondering if there is any procedure to do this.

 

I really appreciate any help.

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

Add your data2 data with data1 and request predicted values. Doesn't work so well for your example data but should do better for your full data, if the model makes sense :

 

data data3;
set data1 data2;
run;

PROC GLM DATA=data3;
CLASS access;
MODEL cost= healthscore access age/ SOLUTION;
output out=data4 predicted=predCost;
RUN;

Look at data4 for predicted values.

PG

View solution in original post

4 REPLIES 4
PaigeMiller
Diamond | Level 26

Either PROC SCORE; or create a new data set by appending data2 to data1, in such a way that COST is missing for the data2 records; then re-run PROC GLM on this new dataset.

--
Paige Miller
Reeza
Super User

PROC PLM

https://documentation.sas.com/?docsetId=statug&docsetVersion=15.1&docsetTarget=statug_plm_examples01...

 

PROC SCORE

https://documentation.sas.com/?docsetId=statug&docsetTarget=statug_score_examples02.htm&docsetVersio...

 

CODE statement + data step

https://documentation.sas.com/?docsetId=statug&docsetTarget=statug_glm_syntax05.htm&docsetVersion=15...

 


@inbalia wrote:
DATA data1;
INPUT obs age healthscore cost access$;
DATALINES;
1 37.1744 2.74061 918.92 2
2 56.8510 0.98697 7.29 1
3 62.6610 2.18619 1322.09 1
4 31.3702 3.80720 930613.57 4
5 60.0573 2.12735 972069.19 2
;
RUN;

PROC GLM DATA=data1;
CLASS access;
MODEL cost= healthscore access age/ SOLUTION;
RUN;

DATA data2;
INPUT obs age healthscore access$;
DATALINES;
1 62.6610 2.18619 1
2 60.0573 2.12735 2
3 61.6390 2.06955 1
4 33.8573 4.19116 3
5 47.2659 1.12857 2
;
RUN;

So I have all regression coefficients from data 1, but now I want to get the predicted values (ideally, the sum of predicted values) when I plug in data2 to the pre-existing regression model. I was wondering if there is any procedure to do this.

 

I really appreciate any help.


 

PGStats
Opal | Level 21

Add your data2 data with data1 and request predicted values. Doesn't work so well for your example data but should do better for your full data, if the model makes sense :

 

data data3;
set data1 data2;
run;

PROC GLM DATA=data3;
CLASS access;
MODEL cost= healthscore access age/ SOLUTION;
output out=data4 predicted=predCost;
RUN;

Look at data4 for predicted values.

PG
inbalia
Calcite | Level 5
Thank you very much! I am new to SAS and couldn't figure out PROC SCORE yet, but this worked wonderfully.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 4 replies
  • 768 views
  • 5 likes
  • 4 in conversation