Solved
Contributor
Posts: 38

# Compute Mean Square Error on validation data set

I split my data into 70% training 20% validation and 10% test sets.

and i run this code :

```proc genmod data=valid;
class sexe country job;
model price = country sexe job / dist=gamma link=log;
run;```

how can I compute Mean Square Error on validation data set?

Accepted Solutions
Solution
‎03-20-2017 08:09 AM
Super User
Posts: 10,784

## Re: Compute Mean Square Error on validation data set

Use CODE statement to get VALID table 's predict value.

Once you got predict value , it is easy to get MSE.

``````proc genmod data=train;
class sex country job;
code file='c:\mycode.sas';
run;
data Score;
set vallid(rename=(price=old_price)) end=last;
%include 'c:\mycode.sas';

sum+(price-old_price)**2;
if last then mse=sum/_n_;
run;
``````

All Replies
Solution
‎03-20-2017 08:09 AM
Super User
Posts: 10,784

## Re: Compute Mean Square Error on validation data set

Use CODE statement to get VALID table 's predict value.

Once you got predict value , it is easy to get MSE.

``````proc genmod data=train;
class sex country job;
code file='c:\mycode.sas';
run;
data Score;
set vallid(rename=(price=old_price)) end=last;
%include 'c:\mycode.sas';

sum+(price-old_price)**2;
if last then mse=sum/_n_;
run;
``````
Contributor
Posts: 38

## Re: Compute Mean Square Error on validation data set

[ Edited ]

why it's

`proc genmod data=train;`

and not :

`proc genmod data=valid;`

I change into "valid" but I got zero as MSE. Is there any function to compute MSE on SAS ?

Super User
Posts: 10,784

## Re: Compute Mean Square Error on validation data set

use TRAIN to get parameter estimator , so you can use it to score VALID data.

Yes.there is function  MSE to compute, check documentation and better use IML code to get MSE.

Super User
Posts: 23,754

## Re: Compute Mean Square Error on validation data set

1. Use STORE statement in PROC GENMOD to get model

2. Use PROC PLM with FITSTATISTICS to score dataset and generate stats.

☑ This topic is solved.