Hi @inid
Basically Sum1 is the sum of value 1 where date1=min(date2) and Sum2 is the sum of value2 where date1=max(date2).
In your example, for client id1, min(date2) corresponds to 05/10/2010 and max(date2) to 05/22/2018. Four records have date1 = min(date2) and no record have date1=max(date2). The sum of value1 would 800 in the first case, and 0 in the second.
So it doesn't match your 'WANT' table.
Could you please explain further what is the exact rule? Wouldn't it be:
Sum1 is the sum of value1 by Client and date1 having date2=min(date2)
Sum2 is the sum of value2 by Client and date1 having date2=max(date2)
If so, you can try this:
proc sql;
create table want as
select Client, date1 format=MMDDYY10., sum(v1) as sum1, sum(v2) as sum2
from (select *, value1*(date2=min(date2)) as v1, value2*(date2=max(date2)) as v2
from have as a
group by client, date1)
group by client, date1;
quit;
Best,
... View more