BookmarkSubscribeRSS Feed
sdixit
Obsidian | Level 7

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
Rick_SAS
SAS Super FREQ

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;
Reeza
Super User

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.

 

 

sdixit
Obsidian | Level 7

Yes, I was talking about mathematical variance of finding the percentage difference of the values. I got another ans to this. Thanks for your help

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Discussion stats
  • 3 replies
  • 1685 views
  • 0 likes
  • 3 in conversation