HI ,
I have a data set like below
Year Claim Loss_paid Loss_Incured
2008 100 500 100
2008 200 1000 200
2009 300 2000 300
2009 400 3000 400
I need to get an output like
Year Claim_Count Loss_PAid Loss_incured
2008 2 1500 300
2009 2 5000 700
Year wise claims counts and sum value of Loss_paid and Loss_Incured
like this?
data have;
input Year Claim Loss_paid Loss_Incured;
datalines;
2008 100 500 100
2008 200 1000 200
2009 300 2000 300
2009 400 3000 400
;
proc sql;
create table want as
select year
,count(Claim) as Claim_Count
,sum(Loss_paid) as Loss_paid
,sum(Loss_Incured) as Loss_Incured
from have
group by year;
quit;
Not clear what you need: dataset or report. If you need a report, try
proc report data=have;
define Year / group;
define Claim / n;
define Loss_Paid / sum;
define Loss_Incured / sum;
run;
and another way to create a data set:
proc summary data=have nway;
class year;
var loss_paid loss_incured;
output out=want (drop=_type_ rename=(_freq_=claim_count))
sum=;
run;
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 lock in 2025 pricing—just $495!
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.