- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I've used the following code to calculate months between two date variables, however, I feel like it's not as accurate as I'd like it to be...
data readms_dist2;
set readms_dist2;
Months_btwn_adms=intck('month', PRV_DC_DT, ADM_DT);
Weeks_btwn_adms=intck('week', PRV_DC_DT, ADM_DT);
Days_btwn_adms=intck('day', PRV_DC_DT, ADM_DT);
run;
From my understanidng, the intck month function just counts if the date has "crossed" into the next month -
So if had a PRV_DC_DT was january 1 2020 and the ADM_DT was january 30 2020, then the function would return 0.
but if PRV_DC_DT was january 30 2020 and ADM_DT was february 1 2020 then the function would return 1. This is correct right? Well, that's not very accurate in calculating how many months between two dates, so what's my best option?
Thanks!
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
IMHO, you would still need to test carefully with "C" and without "C"
Months_btwn_adms=intck('day30', PRV_DC_DT, ADM_DT,"c");
It seems quite likely you would need a 'C' for your custom interval too
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Use 'C' for continuous
Months_btwn_adms=intck('month', PRV_DC_DT, ADM_DT,'c');
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
However, a month does not a standard definition, ie it could be 28 days or 31 days which can be a 10% difference there. It depends on what you need. You can use # of days or some other measure but it depends on what you're calculating and what the rules are.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Yes, ok, I see that's what the other post did with the 'c' for continuous. This is good enough for my purposes 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Makes sense. Is there a way to count by 30 day intervals? Can you use that as the fourth parameter?
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi @accintron Not quite using the fourth argument. But you can use an Interval Multiplier to Create a Custom Interval.
For example day30 as the interval in your case
Months_btwn_adms=intck('day30', PRV_DC_DT, ADM_DT);
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Ah ok! This is great. thanks so much. I'll check out both!
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
IMHO, you would still need to test carefully with "C" and without "C"
Months_btwn_adms=intck('day30', PRV_DC_DT, ADM_DT,"c");
It seems quite likely you would need a 'C' for your custom interval too
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Ok, thank you for this advice. I will try out all three! 🙂