Hi:
First I had to make some data, so I used SASHELP.CLASS and made 2 different versions of it with some changed values (so there would be differences) and with some 0 values.
Then I used PROC SQL to join the two tables by NAME and do the subtraction. I kept EVERYTHING...so you could see what might be useful to you. If you did not want negative numbers, then you might use the ABS function to remove the - sign from the subtraction (as shown for the ABSAGEDIFF variable).
cynthia
[pre]
** make a version of SASHELP.CLASS with different values for;
** age, height and weight;
data class;
set sashelp.class;
age = age + 5;
height = height * 1.05;
weight = weight * 1.05;
** make a few 0 obs;
if name = 'John' then do;
age = 0;
height=0;
weight = 0;
end;
run;
** make some obs with 0 in a second copy of sashelp.class;
data class2;
set sashelp.class;
if name in ('Janet', 'Alfred') then do;
age = 0;
height=0;
weight = 0;
end;
run;
proc sql;
create table newdiff as
select a.name, a.sex, a.age, a.height, a.weight,
b.age as b_age, b.height as b_height, b.weight as b_weight,
a.age - b.age as agediff,
a.height - b.height as htdiff,
a.weight - b.weight as wtdiff,
abs(a.age - b.age) as absagediff
from work.class as a,
work.class2 as b
where a.name = b.name
order by name;
quit;
proc print data=work.newdiff;
run;
[/pre]