# Variance and Standard Deviation in SAS – Row wise and column wise

In order to calculate Variance and Standard deviation in SAS we will be using VAR() and STD() function. In order to calculate row wise variance in SAS we will be using VAR() function in SAS Datastep. In order to calculate column wise variance in SAS we will be using VAR() function in proc sql. In order to calculate row wise standard deviation in SAS we will be using STD() function in SAS Datastep. In order to calculate column wise standard deviation in SAS we will be using STD() function in proc sql. Let’s see an example of each.

• To calculate Row wise variance in SAS we will be using VAR() function in SAS Datastep.
• To calculate Column wise variance in SAS we will be using VAR() function in PROC SQL
• To calculate Row wise standard deviation in SAS we will be using STD() function in SAS Datastep.
• To calculate Column wise standard deviation in SAS we will be using STD() function in PROC SQL

So we will be using EMP_DET Table in our example #### Variance in SAS – Row wise Variance- SAS

We will be using VAR() function in SAS datastep to calculate row wise variance.

```/* Row wise Variance */

data EMP_DET1;
set EMP_DET;
var_salary = VAR(salary_2020,salary_2019,salary_2018);
run;

```

So the resultant table with row wise variance calculated will be #### Column Variance in SAS – Populate variance of column in SAS

We will be using VAR() function in PROC SQL to calculate column wise variance.

```/* populate column wise Variance */

proc sql;
create table EMP_DET1 as (select*,var(salary_2020) as var_salary from EMP_DET);
run;

```

So the resultant table with column wise variance calculated will be #### Row Standard deviation in SAS – Row wise Standard Deviation in SAS

We will be using STD() function in SAS Datastep to calculate row wise standard deviation.

```/* Row wise standard deviation */

data EMP_DET1;
set EMP_DET;
SD_salary = STD(salary_2020,salary_2019,salary_2018);
run;

```

So the resultant table with row wise standard deviation calculated will be #### Column Standard deviation in SAS – Populate standard deviation of column in SAS

We will be using STD() function in PROC SQL to calculate column wise standard deviation.

```/* populate column wise standard deviation */

proc sql;
create table EMP_DET1 as(select*,std(salary_2020) as SD_salary from EMP_DET);
run;

```

So the resultant table with column wise standard deviation calculated will be 