- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi guys,
how can I calculate person-years from two dates for ex: 16FEB2019 and 08JAN2020?
I have two variables with around 20.000 rows in my table.
Thank you in advance.
Best
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Based on your very lean description the two variables with dates you want to compare are in the same row. And what is a person-year? Below assumes it's just a count of calendar years.
data demo;
dt1='16FEB2019'd;
dt2='08JAN2020'd;
format dt1 dt2 date9.;
n_calendar_years=intck('year',dt1,dt2)+1;
run;
proc print data=demo;
run;
What could really help to explain things and remove ambiguity is if you provide some representative sample data and show us the desired result.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Please tell us the desired outcome for the case where the two variables have values 16FEB2019 and 08JAN2020
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
This gives the same information as before. This doesn't answer the question. How many person-years is that?
Paige Miller
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Based on your very lean description the two variables with dates you want to compare are in the same row. And what is a person-year? Below assumes it's just a count of calendar years.
data demo;
dt1='16FEB2019'd;
dt2='08JAN2020'd;
format dt1 dt2 date9.;
n_calendar_years=intck('year',dt1,dt2)+1;
run;
proc print data=demo;
run;
What could really help to explain things and remove ambiguity is if you provide some representative sample data and show us the desired result.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@NewUsrStat wrote:
Hi guys,
how can I calculate person-years from two dates for ex: 16FEB2019 and 08JAN2020?
I have two variables with around 20.000 rows in my table.
Thank you in advance.
Best
You left out most (if not all) of the necessary information.
You probably have some data in addition to those two dates. What does the data look like? Show a small example (2 or three persons) and what result you want for that example data.
Will you have other date ranges you want to summarize? Where will the two dates needed to define those ranges coming from?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
proc sql ;
select sum(date2-date1)/365.25
from have
;
quit ;
Next webinar will be in March 2025. Until then, check out our archives: https://www.basug.org/videos. And be sure to subscribe to our our email list.