SAS Data Science

Building models with SAS Enterprise Miner, SAS Factory Miner, SAS Viya (Machine Learning), SAS Visual Text Analytics, with point-and-click interfaces or programming
BookmarkSubscribeRSS Feed
ainlayray
Fluorite | Level 6

Im using SAS 9.4 

So, I have a car data. I want to split data into training data and test data based on a variable "model year".

I want model year which is even to be training data and model year which is odd to be test data.

I tried the following code:

 

proc import out=work.car5
datafile= "C:\desktop\Auto1.csv" dbms=csv;
getnames=yes; datarow=2;
run;

data train test; 
set year;
b=mod(year,2);
if b=0
then output train;
else output test;
run;

 

but i got some error message. it did not work. How to solve this problem??  Thanks in advance!! 

 

4 REPLIES 4
andreas_lds
Jade | Level 19

@ainlayray wrote:

...

 but i got some error message. it did not work. How to solve this problem??  Thanks in advance!! 

 


This is normal logic: if you get an error message something did not work. So please post the log that we can see that message.

ainlayray
Fluorite | Level 6

NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.TRAIN may be incomplete. When this step was stopped there were 0
observations and 2 variables.
WARNING: The data set WORK.TEST may be incomplete. When this step was stopped there were 0
observations and 2 variables.

 

oh i see. im new here. This is the error message after the code. It created 2 new sets but 0 observations...

andreas_lds
Jade | Level 19

Sorry, my request was misleading: please post the complete log including all steps that are executed.

ainlayray
Fluorite | Level 6

thanks!

okay, I will post in that format in my next posts.  I will post the complete code and log.

 

And I just solved my problem. In my command: "set year" , it refers to year data, not year variable.

so, I changed that to "set car5" which refers to my data. Then it worked... It is like many beginners' mistake...

 

Thanks anyways!!

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

How to choose a machine learning algorithm

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.

Discussion stats
  • 4 replies
  • 2085 views
  • 1 like
  • 2 in conversation