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.
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.
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.
PROC PLM
PROC SCORE
CODE statement + data step
@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.
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.
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.