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:
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.