Sas 简明教程
SAS - Linear Regression
线性回归用于识别因变量与一个或多个自变量之间的关系。提出了关系模型,参数值的估计值用来开发估计回归方程式。
Linear Regression is used to identify the relationship between a dependent variable and one or more independent variables. A model of the relationship is proposed, and estimates of the parameter values are used to develop an estimated regression equation.
然后使用各种检验来确定模型是否令人满意。如果是,那么估计回归方程可以用来预测给定自变量值时的因变量值。在 SAS 中,过程 PROC REG 用于发现两个变量之间的线性回归模型。
Various tests are then used to determine if the model is satisfactory. If it is then, the estimated regression equation can be used to predict the value of the dependent variable given values for the independent variables. In SAS the procedure PROC REG is used to find the linear regression model between two variables.
Syntax
在 SAS 中应用 PROC REG 的基本语法是:
The basic syntax for applying PROC REG in SAS is −
PROC REG DATA = dataset;
MODEL variable_1 = variable_2;
以下是所用参数的描述 -
Following is the description of the parameters used −
-
Dataset is the name of the dataset.
-
*variable_1 and variable_2 * are the variable names of the dataset used in finding the correlation.
Example
下面的示例演示了使用 PROC REG. 发现汽车马力和重量这两个变量之间的相关性的过程。在结果中,我们看到截距值,可以用它来形成回归方程式。
The below example shows the process to find the correlation between the two variables horsepower and weight of a car by using PROC REG. In the result we see the intercept values which can be used to form the regression equation.
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 the above code is executed, we get the following result −
以上的代码还给出了模型的各种估计的图形视图,如下所示。作为一个高级的 SAS 过程,它不仅仅停留在给出典值作为输出。
The above code also gives the graphical view of various estimates of the model as shown below. Being an advanced SAS procedure it simply does not stop at giving the intercept values as the output.