06-17-2016 03:12 PM - edited 06-17-2016 03:13 PM
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.
06-17-2016 03:26 PM - edited 06-17-2016 03:35 PM
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;
06-17-2016 03:27 PM
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.