turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- Base SAS Programming
- /
- Comparing date intervals of similar observations, ...

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

03-16-2018 03:13 PM

Hello,

I have one dataset with 12992 observations. I have (half) 6496 different IDs, so 6496 pairs of observations. What I want to do is to compare date intervals within each pair to make sure they don't overlap eachother for the same ID. The dates variables are DATE9. format and informat.

So basically 3 variables: ID, DATE_BEGIN, DATE_END. I am not sure how to proceed with this.

Thank you

Accepted Solutions

Solution

03-16-2018
03:51 PM

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to x2PSx

03-16-2018 03:19 PM

1. Sort your data so that its consecutive ids

2. Use LAG() to get the previous values

3. Check for overlap

@x2PSx wrote:

Hello,

I have one dataset with 12992 observations. I have (half) 6496 different IDs, so 6496 pairs of observations. What I want to do is to compare date intervals within each pair to make sure they don't overlap eachother for the same ID. The dates variables are DATE9. format and informat.

So basically 3 variables: ID, DATE_BEGIN, DATE_END. I am not sure how to proceed with this.

Thank you

All Replies

Solution

03-16-2018
03:51 PM

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to x2PSx

03-16-2018 03:19 PM

1. Sort your data so that its consecutive ids

2. Use LAG() to get the previous values

3. Check for overlap

@x2PSx wrote:

Hello,

I have one dataset with 12992 observations. I have (half) 6496 different IDs, so 6496 pairs of observations. What I want to do is to compare date intervals within each pair to make sure they don't overlap eachother for the same ID. The dates variables are DATE9. format and informat.

So basically 3 variables: ID, DATE_BEGIN, DATE_END. I am not sure how to proceed with this.

Thank you

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to Reeza

03-16-2018 03:51 PM

I just did, thank you!