My data looks like this
Policy Number | Policy Start date | Policy End date | Policy Term | Age |
101 | 10-Aug-15 | 8-Aug-18 | 3 | 58 |
102 | 25-Feb-16 | 23-Feb-18 | 2 | 55 |
i need the output in the below format. i wanted to break policy start date and Policy end date into years by adding 364 days
Policy Start date | Policy End date | Policy End date | Start Date | End date | Policy Term | Age | Policy Year |
101 | 10-Aug-15 | 8-Aug-18 | 10-Aug-15 | 8-Aug-16 | 3 | 58 | 1 |
101 | 10-Aug-15 | 8-Aug-18 | 9-Aug-16 | 8-Aug-17 | 3 | 59 | 2 |
101 | 10-Aug-15 | 8-Aug-18 | 9-Aug-17 | 8-Aug-18 | 3 | 60 | 3 |
102 | 25-Feb-16 | 23-Feb-18 | 25-Feb-16 | 23-Feb-17 | 2 | 55 | 1 |
102 | 25-Feb-16 | 23-Feb-18 | 24-Feb-17 | 23-Feb-18 | 2 | 56 | 2 |
Please let me know if you any query. Can someone help me on this for me.
You could:
data have;
input PolicyNumber PolicyStartdate :date7. PolicyEnddate :date7. PolicyTerm Age ;
format PolicyStartdate PolicyEnddate date7.;
datalines;
101 10-Aug-15 8-Aug-18 3 58
102 25-Feb-16 23-Feb-18 2 55
;
data want;
set have;
do policyyear=1 to policyterm;
if policyyear=1 then startdate=PolicyStartdate;
else if Policyyear>1 then do;
startdate=enddate+1;
age=age+1;
end;
enddate =intnx('year',PolicyEnddate , -1*(policyterm-policyyear), 's');
output;
end;
format startdate enddate date7.;
run;
data have;
input Policy_Number$ (Policy_Start_date Policy_End_date)(:date9.) Policy_Term Age;
format Policy_Start_date Policy_End_date date9.;
datalines;
101 10-Aug-15 8-Aug-18 3 58
102 25-Feb-16 23-Feb-18 2 55
;
data want(drop=i);
format Policy_Number Policy_Start_date Policy_End_date StartDate EndDate Policy_Term Age PolicyYear;
set have;
do i=1 to Policy_Term;
if i=1 then StartDate=Policy_Start_date;
else StartDate=EndDate+1;
EndDate=intnx('day', StartDate, 364, 'sameday');
age+1;
PolicyYear=i;
output;
end;
format StartDate EndDate date9.;
run;
data have;
input Policy_Number$ (Policy_Start_date Policy_End_date)(:date9.) Policy_Term Age;
format Policy_Start_date Policy_End_date date9.;
datalines;
101 10-Aug-15 8-Aug-18 3 58
102 25-Feb-16 23-Feb-18 2 55
;
data want;
set have;
start=Policy_Start_date;
_age=age;
do PolicyYear=1 to Policy_Term;
age=_age+PolicyYear-1;
end=intnx('month',Policy_End_date,-PolicyYear+1,'s');
output;
start=end+1;
end;
format start end date9.;
drop _age ;
run;
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.
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.