This was a homework question I did in R. Now, I want to practice SAS coding.
So, I want to do it again in SAS to see if output match with what I did in R.
I do not know how to fit test data after I fit training data.
Here is what I did, SAS 9.4 code I have so far:
proc import out=work.car5
datafile= "C:\newRay\uofacourses\Stat441\assignment1\Auto1.csv" dbms=csv;
getnames=yes; datarow=2;
run;
data car6;
set work.car5;
if mpg>=23 then GC="Y";
else GC="N";
run;
data train test;
set car6;
b=mod(year,2);
if b=0
then output train;
else output test;
run;
proc logistic data=train;
model GC = cylinders displacement horsepower weight acceleration year;
run;
So, I import the auto data. I created a new variable called "GC" which means good car with mpg above median. So, GC=Y means yes it is a good car. otherwise is GC=N with mpg below median. I split the data into training and test data based on model year. Even year goes to training data. Odd year goes to test data. Then I fit logistic regression with training data.
This code works fine. I do not know what to do next.
So, next I want to use the model fitted in training data for test data. Then find predicted outcome and compare to real outcome in test data. For test data,
Test error rate=("number of cases predicted as Y but real data is N"+"number of cases predicted as N but real data is Y")/total cases
How can I do this whole task in SAS?
I have also attach my data file. If anyone can help by providing some useful code or guide, I will appreciate it. Thanks in advance!
Hello,
I think that you want to look into how to score a data set with a model that was fit on a different data set. This is a pretty good example of how to do this:
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.
Find more tutorials on the SAS Users YouTube channel.