Help using Base SAS procedures

Regarding Date logic

Reply
Frequent Contributor
Posts: 90

Regarding Date logic

Hi All,

For each member number we need to look at the discharge date should be less than 30 days of the next admit date, if so Y else N on the Readmission variable. Please let me know how to apply date logic for this.

Member_Number      Claim_ID         Admit_Date     Discharge_Date Readmission

420000000694600   0102241579644   2/15/2015       2/19/2015

420000000694600   0102121583902   2/2/2015         2/6/2015

420000000694600   0101161597102   1/6/2015          1/8/2015

420000009817200   0106101514987   5/26/2015       5/28/2015

420000009817200   0105051585970   4/18/2015       4/24/2015

420000009817200   0104151510931   4/1/2015           4/3/2015

420000009817200   0103241584788   3/10/2015       3/14/2015

Thanks for your help.

Esteemed Advisor
Esteemed Advisor
Posts: 6,977

Re: Regarding Date logic

Hi,

Something like this, assuming dates are date format, and data is sorted.

data want;

     set have;

     if lag(member_number)=member_number and admit_date - 30 <= lag(discharge_date) <= admit_date then result="Y";

     else if lag(member_number)=member_number then  result="N";

run;

Frequent Contributor
Posts: 90

Re: Regarding Date logic

Hi, Thanks for your reply. It doesn't the satisfy the required condition. Your output looks like as below,

MEMBER                      CLAIM           ADMIT            DISCHARGE         result

420000000694600 0102241579646 7/10/2015        7/12/2015

420000000694600 0102241579645 6/15/2015        6/19/2015                    N

420000000694600 0102241579644 2/15/2015       2/19/2015                      N

420000000694600 0102121583902 2/2/2015         2/6/2015                        N

420000000694600 0101161597102 1/6/2015          1/8/2015                       N

420000009817200 0106101514987 5/26/2015        5/28/2015

420000009817200 0105051585970 4/18/2015       4/24/2015                       N

420000009817200 0104151510931 4/1/2015          4/3/2015                        N

420000009817200 0103241584788 3/10/2015        3/14/2015                          N

Respected Advisor
Posts: 3,124

Re: Regarding Date logic

's solution is based on a presumption that your data is sorted first by member , then by admit. do this first, then run his code:

proc sort data=have want=sort_have;

by member admit;

run;

Ask a Question
Discussion stats
  • 3 replies
  • 244 views
  • 3 likes
  • 3 in conversation