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;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.