BookmarkSubscribeRSS Feed
dincoo
SAS Employee

 

Hi,

 

There are the insurance policies with customer_id, policy_id, revision_id and policy start and end dates.

I want to calculate the day between the renewal of two policies for the same customer

 

Some policies may have revisions (added some extra coverage) with same policy_id and end_date.

 

Here is the sample data:

 

 Capture.JPG

 

For example for the policies 1247 and 1389, renewal day is: 365

For 1389 and 1543 it is: 0

 

 

 

Thank you very much!

Onur

 

4 REPLIES 4
Reeza
Super User

Use the lag function to obtain the previous value of the end date.

 

data want;
set have;
by customerID;

contract_end = lag1(end_date);

if first.customerID then do;
   renewal=.;
end;
else renewal = datepart(start_date)-datepart(contract_end);

run;
dincoo
SAS Employee

Hi Reeza,

 

Thank you for your reply.

The problem is many policies have revisions -as ı stated at example- with the same policy_id and end_date and different start_date (revision_date).

I want the date difference only between different policy_ids.

 

Do you have any idea?

 

Thank you!

Reeza
Super User
What do you want the output to look like? Do you keep the revisions in the file? If so, what should duration be.
dincoo
SAS Employee
I just want to choose the customers who's min 2 different policy_ids and the date between ex policy end date and new policy date are greater than 1 month

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