BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
harrylui
Obsidian | Level 7

Dear all,

 

this is my data set 

 

ProductUWYearAccidentYearMonthMasterPolicyPolicyHolderProducerNameClaimNoCoverageLossIncurred 
ABC2018201809ACEGT00787parklalala404556320501ZG-2,547,181
ABC2018201809ACEGT00787parklalala404556320501ZG60
ABC2018201809ACEGT00787parklalala404556320501ZG2,547,181
ABC2018201809ACEGT00787parklalala404556320501ZG-60
ABC2018201810ACEGT00787parklalala404556320501ZG5,347
ABC2018201810ACEGT00787parklalala404556320501ZG-5,347
Other2016201603ACEGT00739asialelele518002612155ZG-1,041
Other2016201603ACEGT00739asialelele518002612155ZG1,041
Other2016201603ACEGT00739asialelele518002612155ZG1,040
Other2016201603ACEGT00739asialelele518002612155ZG-729
Other2016201603ACEGT00739asialelele518002612155ZG729
Other2016201603ACEGT00739asialelele518002612155ZG728
Other2016201603ACEGT00739asialelele518002612155ZG729
Other2016201603ACEGT00739asialelele518002612155ZG-729
Other2016201603ACEGT00739asialelele518002612155ZG

-728

 

 

I want to group it using ClaimNo and lossincurred as a main grouping 

 

the expected output list below 

 

ProductUWYearAccidentYearMonthMasterPolicyPolicyHolderProducerNameClaimNoCoverageLossIncurred 
ABC2018201810ACEGT00787parklalala404556320501ZG0
Other2016201603ACEGT00739asialelele518002612155ZG1040

 

can anyone help me with this

 

if possible,please tell me how to transform -2,547,181  into negative numeric number in sas

 

 

Thank you all

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

SQL can do it simply:

proc sql;
create table want as
select
  Product,UWYear,AccidentYearMonth,MasterPolicy,
  PolicyHolder,ProducerName,ClaimNo,Coverage,
  sum(lossincurred) as lossincurred
from have
group by
  Product,UWYear,AccidentYearMonth,MasterPolicy,
  PolicyHolder,ProducerName,ClaimNo,Coverage
;
quit;

Note that -2,547,181 is already a valid numeric value, if the column type is numeric. Otherwise, convert by using the comma. informat:

data test;
charvar = "-2,547,181";
numvar = input(charvar,comma12.);
run;

View solution in original post

2 REPLIES 2
Kurt_Bremser
Super User

SQL can do it simply:

proc sql;
create table want as
select
  Product,UWYear,AccidentYearMonth,MasterPolicy,
  PolicyHolder,ProducerName,ClaimNo,Coverage,
  sum(lossincurred) as lossincurred
from have
group by
  Product,UWYear,AccidentYearMonth,MasterPolicy,
  PolicyHolder,ProducerName,ClaimNo,Coverage
;
quit;

Note that -2,547,181 is already a valid numeric value, if the column type is numeric. Otherwise, convert by using the comma. informat:

data test;
charvar = "-2,547,181";
numvar = input(charvar,comma12.);
run;
harrylui
Obsidian | Level 7

thank you

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 710 views
  • 0 likes
  • 2 in conversation