BookmarkSubscribeRSS Feed
ambadi007
Quartz | Level 8

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

3 REPLIES 3
PeterClemmensen
Tourmaline | Level 20

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;
andreas_lds
Jade | Level 19

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;
ballardw
Super User

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;

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 888 views
  • 0 likes
  • 4 in conversation