Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

SAS linear regression


May 27, 2021 SAS


Table of contents


Linear regression is used to identify the relationship between a cause variable and one or more independent variables. A model of the relationship is proposed and an estimated regression equation is formed using the estimate of the parameter values.

Various tests are then used to determine whether the model is satisfactory. I f so, you can use the estimated regression equation to predict the value of a given value of the argument's cause variable. I n SAS, the program PROC REG is used to find a linear regression model between two variables.

Grammar

The basic syntax for applying PROC REG in SAS is:

PROC REG DATA = dataset;
MODEL variable_1 = variable_2;

The following is a description of the parameters used:

  • Dataset is the name of the dataset.
  • variable_1 and variable_2 are variable names for datasets that are used to find correlations.

Cases

The following example shows the process of using PROC REG to find the correlation between two variables of horsepower and weight in a car. I n the result, we see intercept values that can be used to form regression equations.

PROC SQL;
create table CARS1 as
SELECT invoice,horsepower,length,weight
 FROM 
SASHELP.CARS
WHERE make in ('Audi','BMW')
;
RUN;
proc reg data=cars1;
model horsepower= weight ;
run;

When we execute the code above, we get the following results:

SAS linear regression

The above code also gives a graphical view of the various estimates of the model, as shown below. A s an advanced SAS program, it does not stop giving intercept values as output.

SAS linear regression SAS linear regression