DATA Step, Macro, Functions and more

Finding a Date within a range

Accepted Solution Solved
Reply
Contributor
Posts: 70
Accepted Solution

Finding a Date within a range

I'm trying to figure out a way of determing if a particular date is within a date range.  For example in the dataset below.  I want to see if Person ID 1 was covered on Oct 1, 2014.   Is there an easy way to figure this out?

 

Person ID           Date Begin             Date End            Program

1                          01/01/2014           09/30/2014         AD

1                          11/01/2014           12/31/2014         BB

 


Accepted Solutions
Solution
‎09-15-2016 03:39 PM
Super User
Posts: 19,875

Re: Finding a Date within a range

Sure. How do you want to deal with multiple records per ID? Also, is it possible to have missing values? If so, the logic would need to be adjusted.

 

if date_start <= "01Oct2014"d <= date_end then coverage=1;
else coverage=0;

View solution in original post


All Replies
Solution
‎09-15-2016 03:39 PM
Super User
Posts: 19,875

Re: Finding a Date within a range

Sure. How do you want to deal with multiple records per ID? Also, is it possible to have missing values? If so, the logic would need to be adjusted.

 

if date_start <= "01Oct2014"d <= date_end then coverage=1;
else coverage=0;
Contributor
Posts: 70

Re: Finding a Date within a range

Thank you!  This worked out perfectly!

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 2 replies
  • 256 views
  • 0 likes
  • 2 in conversation