I have two SAS data sets of this kind.
Data set A
Data set B
The Output which i am expecting is as shown below. This is nothing but Data set A - Data set B
I am very much new to SAS so I am not able to understand on how to Merge these two Datasets and find the Difference between the Values. Also one more challenge which I am facing here is the Merging should be done on Row to Row basis instead of Columns. i.e. for example
The value in First Column should match with the Value of First column in the Dataset b.
Then if that Matches the Values in Second columns should match. If they Match then the values in the 3rd Columns should get subtracted.
Even if I am not able to Merge two Datasets is there any other way to find the differences between the values and store it in a New SAS output File.
Can someone please help me on this. Thanks in Advance.
hWill this work:
data have1;
m = 'x'; n = 'a'; val = 1; output;
m = 'x'; n = 'b'; val = 23; output;
m = 'y'; n = 'e'; val = 12; output;
m = 'y'; n = 'f'; val = 13; output;
run;
data have2;
m = 'x'; n = 'a'; val = 2; output;
m = 'x'; n = 'b'; val = 3; output;
m = 'y'; n = 'e'; val = 13; output;
m = 'y'; n = 'f'; val = 15; output;
run;
proc sql;
create table want as
select h1.m, h1.n, h1.val - h2.val from have1 h1, have2 h2 where h1.m = h2.m and h1.n = h2.n;
quit;
Column m has no effect here actually since n is unique when m changes. Maybe it is just the way you presented your example