Learning SAS? Welcome to the exclusive online community for all SAS learners.

Splitting, Training and Test

Reply
Regular Learner
Posts: 1

Splitting, Training and Test

Hello, I am a SAS novice and learning SAS on my own. Here is what I'm trying to do:

 

1. Import my data from excel and splitt all data (500 values) into 300 values for "Training" and 200 values for "Testing" - done

2. Run a proc univariate and a proc reg for "Training" to obtain the ^y regression equiation - done

3. Run a proc reg for "Testing" to obtain the predicted ^y - done

4. Use the "Training" ^y regresion equation with his betas to calculate the "Testing" real ^y with the 200 values for Testing

5. Compare MSE from the predicted ^y and real ^y

 

Steps 1 to 3 I have it done, but 4 and 5 I don´t know how to do it, mostly the step 4. 

 

This is my code at the moment: 

 

STEP 1

proc import

datafile='C:\Data.xls'

dbms=xls out=Data replace;

 

proc surveyselect data=Data (firstobs=1 obs=300) n=300

out=DataTrain outall method=seq; run;

 

proc surveyselect data=Data (firstobs=301 obs=506) n=206

out=DataTest outall method=seq; run;

 

STEP 2

proc univariate data=DataTrain plot;

run;

data Mod_DataTrain; set DataTrain;

LY=-log(y)

proc reg data=Mod_DataTrain;

model LY = v1 v2 v3 / tol vif collin;

plot r.*p.;

run;

 

STEP 3

data Mod_DataTest; set DataTest;

PredictedY=-log(y);

proc reg data=Mod_DataTest;

model PredictedY = v1 v2 v3 / tol vif collin;

plot r.*p.;

run;

 

If someone could help me I will apreciate it. 

 

Regards, 

Super User
Posts: 10,500

Re: Splitting, Training and Test

It sounds like you are wanting to use the equation from one set of data on another. This is often referred to as scoring.

 

Using proc reg you want to create and OUTEST parameter data set using the TYPE=Parms option.

 

Proc Score will then use that data set with your data to obtain the ^y which you then summarize.

 

Or you can look at the parameters and write an equation in a data step to do the scoring and create the ^y.

Trusted Advisor
Posts: 1,204

Re: Splitting, Training and Test

Hi,

 

Also, does proc surveyselect split the data randomly?

Super User
Posts: 10,500

Re: Splitting, Training and Test


stat_sas wrote:

Hi,

 

Also, does proc surveyselect split the data randomly?


Yes.

If you use right options you could have a selected/not selected flag and you could perhaps see that.

Trusted Advisor
Posts: 1,204

Re: Splitting, Training and Test

 

 

Ask a Question
Discussion stats
  • 4 replies
  • 263 views
  • 0 likes
  • 3 in conversation