Hi,
I have below dataset with 4 coloumns.As shown below Account opening date is different to every account.
after that he may transact in first 3months from account opening date or may not transact.
data account;
input account_no $ acc_open_date :date9. trans_date :date9. transamt;
format acc_open_date trans_date date9.;
datalines;
08660123 02NOV2016 15DEC2016 1000
08660123 02NOV2016 16DEC2016 100
08660123 02NOV2016 19DEC2016 100
08660123 02NOV2016 15JAN2017 1000
08660123 02NOV2016 25JAN2017 1000
08660123 02NOV2016 1FEB2017 1000
08660123 02NOV2016 10FEB2017 1000
08660123 02NOV2016 11FEB2017 1000
08660123 02NOV2016 11MAR2017 1000
08660123 02NOV2016 21MAR2017 1000
08660456 02JUN2016 21OCT2016 1000
08660456 02JUN2016 21NOV2016 1000
08660456 02JUN2016 21DEC2016 1000
;
here i would need sum(transamt) for the first 3months(if account open month is NOv then trans amount for NOV DEC JAN from the account opeinng date group by account no.
in this case i need
08660123 3200
08660456 0
I tried below query but it's not giving me correct result.
proc sql;
select account_no,sum(transamt) as totaltransaction
from account
where month(trans_date) between month(acc_open_date) and month(intnx('month',acc_open_date,2))
group by account_no;
quit;
thank you in adavance.
... View more