Hi, i need to output summary statistics of "Amount" variable, i need to print sum of amount for an each every month. see my below data
table name = transactions_info
policy no Amount Date
1 300 201909
2 600 201909
3 900 201910
4 100 201910
So i need summary output which looks like below
Date Amount
201909 900
201910 1000
Thanks in advance
data have;
input policyno Amount Date : yymmn6.;
format Date yymmn6.;
datalines;
1 300 201909
2 600 201909
3 900 201910
4 100 201910
;
proc summary data=have nway;
class Date;
var Amount;
output out=want(drop=_:) sum=;
run;
Result:
Date Amount 201909 900 201910 1000
data have;
input policyno Amount Date : yymmn6.;
format Date yymmn6.;
datalines;
1 300 201909
2 600 201909
3 900 201910
4 100 201910
;
proc summary data=have nway;
class Date;
var Amount;
output out=want(drop=_:) sum=;
run;
Result:
Date Amount 201909 900 201910 1000
Thank you so much
Alternate method, using SQL:
proc sql;
create table want as
select date, sum(amount) as amount
from have
group by date;
quit;
thank you
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.