BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
accintron
Obsidian | Level 7

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!

 

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20

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 

View solution in original post

10 REPLIES 10
novinosrin
Tourmaline | Level 20

Use 'C' for continuous

 

Months_btwn_adms=intck('month', PRV_DC_DT, ADM_DT,'c');

 

Reeza
Super User
Look at the fourth parameter in the INTCK() function.

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.
accintron
Obsidian | Level 7

Yes, ok, I see that's what the other post did with the 'c' for continuous. This is good enough for my purposes 🙂

Reeza
Super User
This is the reason the standards were set at 30/90/180 re-admission rates though 🙂
accintron
Obsidian | Level 7

Makes sense. Is there a way to count by 30 day intervals? Can you use that as the fourth parameter?

novinosrin
Tourmaline | Level 20

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);

 

accintron
Obsidian | Level 7

Ah ok! This is great. thanks so much. I'll check out both!

novinosrin
Tourmaline | Level 20

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 

accintron
Obsidian | Level 7

Ok, thank you for this advice. I will try out all three! 🙂

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!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 10 replies
  • 7679 views
  • 7 likes
  • 3 in conversation