# How to Use PROC REG in SAS (With Example)

You can use PROC REG in SAS to fit linear regression models.

You can use the following basic syntax to fit a simple linear regression model:

```proc reg data = my_data;
model y = x;
run;```

This will fit the following linear regression model:

y = b0 + b1x

You can use the following basic syntax to fit a multiple linear regression model:

```proc reg data = my_data;
model y = x1 x2 x3;
run;```

This will fit the following linear regression model:

y = b0 + b1x1 + b2x2 + b3x3

The following example shows how to use PROC REG to fit a simple linear regression model in SAS along with how to interpret the output.

## Example: How to Use PROC REG in SAS

Suppose we have the following dataset that contains information on hours studied and final exam score for 15 students in some class:

```/*create dataset*/
data exam_data;
input hours score;
datalines;
1 64
2 66
4 76
5 73
5 74
6 81
6 83
7 82
8 80
10 88
11 84
11 82
12 91
12 93
14 89
;
run;

/*view dataset*/
proc print data=exam_data;
```

We can use PROC REG to fit a simple linear regression model to this dataset, using hours as the predictor variable and score as the response variable:

```/*fit simple linear regression model*/
proc reg data = exam_data;
model score = hours;
run;```

The first table in the output shows a summary of the model fit:

The Parameter Estimates table contains the coefficient estimates for the model.

From this table we can see the fitted regression equation:

Score = 65.33 + 1.98*(hours)

The PROC REG procedure also produces residual plots that we can use to check if the assumptions of the linear regression model are met:

Lastly, the PROC REG procedure produces a scatterplot of the raw data with the fitted regression line overlaid on top:

This plot allows us to visually see how well the regression line fits the data.

Note: You can find the complete documentation for PROC REG here.