Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- Home
- /
- Analytics
- /
- Stat Procs
- /
- Calculation of variance of data in two tables

Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Mute
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Posted 06-17-2016 03:12 PM
(1842 views)

Could anyone help how to create a table having calcuation of variance of two columns in two different tables.

Example : Suppose I have Table A and Table B

Column XYZ in A and ABC in B.

I have to create a table having new variable EFH which tells me the **percentage** **DIFFERENCE** of XYZ and ABC.

Thanks

3 REPLIES 3

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

I don't know what "percentage difference" means, but to get the variances you can either compute the two variances and then merge the results, or you can merge the data and then compute the two variances. Here is the second method;

```
%let ds1 = sashelp.class;
%let var1 = height;
%let ds2 = sashelp.cars;
%let var2 = mpg_city;
data want;
merge &ds1(keep=&var1) &ds2(keep=&var2);
run;
proc means data=want var;
output out=Vars var= / autoname;
run;
proc print; run;
```

If you now want the difference between these variances, write a DATA step:

```
data want;
set Vars;
/* not sure what formula you want to use here... */
format EFH PERCENTN7.2;
EFH = (&var1._Var - &var2._Var) / (&var2._Var);
run;
```

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

It sounds like you're not talking about the statistical definition of variance here but the accounting definition of variance. You should clarify your formula.

You can merge your tables and then calculate the difference, either PROC SQL or a data step will work.

Post sample data for sample code, please include data in the form of a data step so we can read it in directly to SAS.

- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. **Registration is now open through August 30th**. Visit the SAS Hackathon homepage.

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.