But what is the meaning of doing that final subtraction?
Sounds like you are saying if there is only one date you want the total, but if there is two more dates you want the total without the last date.
- I want the total without the observation from last day.
What happens if there are multiple records on the last date? Do you want to subtract all of the values?
-Yes, all the values.
Do you just want the collapsed total per NO_POLICE? Or do you want the total re-merged back onto all of the detailed records?
- Total collapsed without remerging.
Do you want the modified total re-merged onto all of the detail records? Or do you just want the value of that total variable to be different on the last observation.
- I need this result :
My code is correct, but I can't hold the case when I have, fro example, 3 observation with same DATES, I have this :
I need to have 47506,40 in montant2.
Do the D_EFFET variables ever have time of day part? Or are they really just a date value that happens to be stored as datetime values? Perhaps you pulled it from a database like ORACLE or EXCEL that does not really have Date or Time types, just DATETIME? Sorry, I didn't understant the question.
My actual code is :
proc sql;
create table test as select distinct count(distinct(a.D_EFFET)) as nombre,a.NO_POLICE, a.MT_BRUT_CIE,
sum(abs(a.MT_BRUT_CIE)) as montant,sum(abs(a.MT_BRUT_CIE))-abs(a.MT_BRUT_CIE) as montant2, max(datepart(a.D_EFFET)) as date_recente format ddmmyy10., datepart(a.D_EFFET) as date format ddmmyy10.
from PRESTATIONS2 as a
having max(datepart(a.D_EFFET))=datepart(a.D_EFFET)
;
quit;
Thank you !
... View more