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
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and save with the early bird rate—just $795!
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.