Hello,
I saw this code that creates a regression model to use a person's height to predict the person's weight.
I read about defintions of Training dataset and Test(validation) data set.
Training dataset: data used to create the model
Test(validation) data set : data used to qualify performance(check performance of regression model)
I have 3 questions:
1-Why in the code put the train table and test table together? (As I read we need to build the model on the train table only)
2-What is the meaning of outest=est (in proc sgplot)?
3-We saved the resgression equation on macro variable and used it to calculate precited values for new observations from train data.
Is it the only way to do it?
If we have 50 independent varaibles then it might be too long code..
data train;
set sashelp.class(keep=weight height);
run;
data test;
height=71;output;
height=72;output;
run;
data have;
set train test;
run;
proc reg data=have outest=est noprint;
model weight=height;
output out=want predicted=predicted;
run;
proc print data=want noobs;run;
data _null_;
set est;
call symputx('func',cats('weight=',intercept,'+',height,'*height'));
run;
proc sgplot data=train aspect=1;
reg x=height y=weight/ cli clm;
inset "&func"/ position=topleft textattrs=graphdata1(size=12);
run;
@Ronein wrote:
Hello,
I saw this code that creates a regression model to use a person's height to predict the person's weight.
I read about defintions of Training dataset and Test(validation) data set.
Training dataset: data used to create the model
Test(validation) data set : data used to qualify performance(check performance of regression model)
I have 3 questions:
1-Why in the code put the train table and test table together? (As I read we need to build the model on the train table only)
2-What is the meaning of
outest=est (in proc sgplot)?
3-We saved the resgression equation on macro variable and used it to calculate precited values for new observations from train data.
Is it the only way to do it?
If we have 50 independent varaibles then it might be too long code..
data train; set sashelp.class(keep=weight height); run; data test; height=71;output; height=72;output; run; data have; set train test; run; proc reg data=have outest=est noprint; model weight=height; output out=want predicted=predicted; run; proc print data=want noobs;run; data _null_; set est; call symputx('func',cats('weight=',intercept,'+',height,'*height')); run; proc sgplot data=train aspect=1; reg x=height y=weight/ cli clm; inset "&func"/ position=topleft textattrs=graphdata1(size=12); run;
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.