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

Hi,

I have data set where I want to sum of premium for particular Agent_Id and want to update incentive percentage as per their sum of premium amount.

 

Example -

If agent id ='14524' sum of premium = 50000 than Percentage = 10;

else if agent id='17116' sum of premium  greater 50000 and less than 100000 then 12;

else percentage=0;

run;

 

data set =

Agent_Id

Premium

1633655

   800,000

1633655

   400,000

12529

   200,000

12529

   100,000

17116

     50,000

17116

     25,000

14524

     10,000

14524

     10,000

14524

     20,000

 

want result as per below

 

Agent_Id

Premium

Sum Of Premium

Percentage

1633655

   800,000

1200000

 

1633655

   400,000

1200000

 

12529

   200,000

300000

 

12529

   100,000

300000

 

17116

     50,000

75000

12

17116

     25,000

75000

12

14524

     10,000

40000

10

14524

     10,000

40000

10

14524

     20,000

40000

10

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

@sanjaymane7 wrote:

Hi,

I have data set where I want to sum of premium for particular Agent_Id and want to update incentive percentage as per their sum of premium amount.

 

Example -

If agent id ='14524' sum of premium = 50000 than Percentage = 10;

else if agent id='17116' sum of premium  greater 50000 and less than 100000 then 12;

else percentage=0;

run;

 

data set =

Agent_Id

Premium

1633655

   800,000

1633655

   400,000

12529

   200,000

12529

   100,000

17116

     50,000

17116

     25,000

14524

     10,000

14524

     10,000

14524

     20,000

 

want result as per below

 

Agent_Id

Premium

Sum Of Premium

Percentage

1633655

   800,000

1200000

 

1633655

   400,000

1200000

 

12529

   200,000

300000

 

12529

   100,000

300000

 

17116

     50,000

75000

12

17116

     25,000

75000

12

14524

     10,000

40000

10

14524

     10,000

40000

10

14524

     20,000

40000

10


proc summary data=have;
    class agent_id;
    var premium;
    output out=sums sum=sum_of_premium;
run;
data want;
    merge have sums;
    by agent_id;
    if sum_of_premium<50000 then percentage=10;
    else if sum_of_premium<100000 then percentage=12;
    else percentage=0;
run;
    

This assumes your data is sorted by AGENT_ID

--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

@sanjaymane7 wrote:

Hi,

I have data set where I want to sum of premium for particular Agent_Id and want to update incentive percentage as per their sum of premium amount.

 

Example -

If agent id ='14524' sum of premium = 50000 than Percentage = 10;

else if agent id='17116' sum of premium  greater 50000 and less than 100000 then 12;

else percentage=0;

run;

 

data set =

Agent_Id

Premium

1633655

   800,000

1633655

   400,000

12529

   200,000

12529

   100,000

17116

     50,000

17116

     25,000

14524

     10,000

14524

     10,000

14524

     20,000

 

want result as per below

 

Agent_Id

Premium

Sum Of Premium

Percentage

1633655

   800,000

1200000

 

1633655

   400,000

1200000

 

12529

   200,000

300000

 

12529

   100,000

300000

 

17116

     50,000

75000

12

17116

     25,000

75000

12

14524

     10,000

40000

10

14524

     10,000

40000

10

14524

     20,000

40000

10


proc summary data=have;
    class agent_id;
    var premium;
    output out=sums sum=sum_of_premium;
run;
data want;
    merge have sums;
    by agent_id;
    if sum_of_premium<50000 then percentage=10;
    else if sum_of_premium<100000 then percentage=12;
    else percentage=0;
run;
    

This assumes your data is sorted by AGENT_ID

--
Paige Miller
sanjaymane7
Obsidian | Level 7
Thank you. It works

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 2 replies
  • 532 views
  • 0 likes
  • 2 in conversation