Hello, I have an input dataset with 4 important variables: ID, A1, A2, A3. After processing it, I've split it into 5 datasets: ERR1, ERR2, ERR3, MODEL, NEWINPUT, with the same inputs. I need to validate the results so I'm trying to do a query to see if: SUM(input.A1) is equal to SUM( SUM(ERR1.A1), SUM(ERR2.A1) ....., SUM(NEWINPUT.A1) ) Also I need to group it by ID. My output should look like this: ID INPUT_A1 OUTPUT_A1 INPUT_A2 OUTPUT_A2 INPUT_A3 OUTPUT_A3
1 SUM(input.A1) SUM( SUM(ERR1.A1), SUM(ERR2.A1) .....) ... ... ... ...
My current code, which is not working, looks like this: proc sql;
select coalesce(a.Id, b.Id, c.Id, d.Id, e.Id, f.Id) as ID,
sum(a.A1) as IN_A1,
sum( sum(b.A1), sum(c.A1), sum(d.A1), sum(e.A1), sum(f.A1) ) as OUT_A1,
sum(a.A2) as IN_A2,
sum( sum(b.A2), sum(c.A2), sum(d.A2), sum(e.A2), sum(f.A2) ) as OUT_A2,
sum(a.A3) as IN_A3,
sum( sum(b.A3), sum(c.A3), sum(d.A3), sum(e.A3), sum(f.A3) ) as OUT_A3
from Input as a,
err.err1 as b,
err.err2 as c,
err.err3 as d,
err.model as e,
err.newinput as f
where a.Id=b.Id=c.Id=d.Id=e.Id=f.Id
group by calculated ID;
quit; Any help?
... View more