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
- /
- Learn SAS
- /
- Analytics U
- /
- Checking number of visits over time within a 2 yr ...

Topic Options

- Subscribe to 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
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content

a month ago

I have a situation where patients have multiple physician visits over time. To be qualified they need to have at least 4 visits during a 2 year period of time starting with first visit. If starting with the first visit and there are less than 4 visits during the 2 yrs then start with the second visit and keep looking until they qualify. Any suggestions please.

Thank you

Phil

Thank you

Phil

Accepted Solutions

Solution

3 weeks ago

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

a month ago - last edited a month ago

Assuming your visit date variable is a SAS date, this gives you a list of qualified patients ...

proc sort data=have;

by patient visit_dt;

run;

data want;

set have;

by patient;

if first.patient then do;

qualfied='N';

n_visits = 1;

end;

else n_visits + 1;

duration = dif3(visit_dt);

if n_visits >= 4 and duration <= 730 then qualified='Y';

retain qualified;

if last.patient;

run;

Hope it's acceptable to use 730 days as the measurement, and ignore leap years.

********************************

EDITED:

@mkeintz you're absolutely right. Correction is in place now. Thanks.

All Replies

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

a month ago

Is the patient visit data short and wide or long and narrow? In other words, In your data, do you have an observation (row) for every patient visit, or do you have multiple variables in the same patient row for multiple visits?

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

4 weeks ago

Thank you for the response,

My data is long, one patient has multiple observations with distinct visit dates.

PAt_id visit

101 date1

101 date2

101 date3

105 date1

105 date2

105 date3 and so on..

Solution

3 weeks ago

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

a month ago - last edited a month ago

Assuming your visit date variable is a SAS date, this gives you a list of qualified patients ...

proc sort data=have;

by patient visit_dt;

run;

data want;

set have;

by patient;

if first.patient then do;

qualfied='N';

n_visits = 1;

end;

else n_visits + 1;

duration = dif3(visit_dt);

if n_visits >= 4 and duration <= 730 then qualified='Y';

retain qualified;

if last.patient;

run;

Hope it's acceptable to use 730 days as the measurement, and ignore leap years.

********************************

EDITED:

@mkeintz you're absolutely right. Correction is in place now. Thanks.

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

a month ago

@Astounding I think you need dif3, not dif4.

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

4 weeks ago

Thank you for sharing this , I will try the SAS code.

Appreciate your help!

Appreciate your help!