SET BY with FIRST. and LAST. Help

Reply
New Contributor
Posts: 3

SET BY with FIRST. and LAST. Help

I need help in the code snippet below. if the value of BREAKDAY = 30; what values will be populated in the Final_Start and Last_End columns? I don't have SAS environment available to test it out.

Any help is appreciated.

DATA MEM_ELIG;

SET &DATA.;

BY MEMBER_ID BEGIN_DATE_S END_DATE_S;

RETAIN FINAL_START LAST_END ;

IF FIRST.MEMBER_ID THEN DO;

LAST_END=END_DATE_S;

FINAL_START=BEGIN_DATE_S;

END;

ELSE IF BEGIN_DATE_S-LAST_END-1 LE &BREAKDAY. THEN DO;

LAST_END=MAX(END_DATE_S, LAST_END);

END;

ELSE DO;

LAST_END=END_DATE_S;

FINAL_START=BEGIN_DATE_S;

END;

RUN;

MEMBER_ID  BEGIN_DATE_SEND_DATE_SMEMBER_IDBEGIN_DATE_SEND_DATE_SFinal_StartLast_End
FirstLastFirstLastFirstLast
10011/1/20123/1/2012101111
10014/1/20126/1/2012001111
10016/1/201212/31/2099011111
10021/1/20123/1/2012101111
10023/15/201212/31/2099011111
10031/1/20123/1/2012101111
10035/1/201212/31/2099011111
10041/1/201212/31/2099111111
PROC Star
Posts: 7,363

Re: SET BY with FIRST. and LAST. Help

What is the value of &breakday.?

Super Contributor
Posts: 1,636

Re: SET BY with FIRST. and LAST. Help

Hi Art,

from OP's post:  "if the value of BREAKDAY = 30;"

does this mean &breakday=30?

New Contributor
Posts: 3

Re: SET BY with FIRST. and LAST. Help

breakday = 30

PROC Star
Posts: 7,363

Re: SET BY with FIRST. and LAST. Help

01/01/2012 03/01/2012  

01/01/2012 06/01/2012  

01/01/2012 12/31/2099  

01/01/2012 03/01/2012  

01/01/2012 12/31/2099  

01/01/2012 03/01/2012  

05/01/2012 12/31/2099  

01/01/2012 12/31/2099

New Contributor
Posts: 3

Re: SET BY with FIRST. and LAST. Help

It helped. Thanks. I guess that the 2nd and 3rd row's first date would be 4/1/2012...Is that correct?

PROC Star
Posts: 7,363

Re: SET BY with FIRST. and LAST. Help

I ran your code, printed the resulting file, and posted the two columns you asked about.

Ask a Question
Discussion stats
  • 6 replies
  • 279 views
  • 0 likes
  • 3 in conversation