BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
skavyasindhu
Fluorite | Level 6

Hello,

I need help with the claims data that i am working with.

data have;

      input person_sk service_dt:mmddyy.;
      cards;
     001 04/01/2014 
     001 01/01/2014 
     001 01/15/2014 
     001 03/01/2014 
     001 03/03/2014 
     001 04/15/2014 
     002 05/1/2014 
     002 10/1/2014 
     ;
run;

 

I need to identify the service_dt that is immediately 30 days after the first service_dt. This will be my first trigger date. Then i need to count the number of days from first trigger date and identify the second trigger date that comes immediately 30 days after the first trigger date.

I need the data set to be like

     person_sk service_dt trigger_date

     001 01/01/2014  1
     001 01/15/2014  0
     001 03/01/2014  1
     001 03/03/2014  0

     001 04/02/2014  1
     001 04/15/2014  0
     002 05/1/2014 1
     002 10/1/2014  1

 

Can anyone help me?

 

Thank you!!

1 ACCEPTED SOLUTION

Accepted Solutions
novinosrin
Tourmaline | Level 20
data have;

      input person_sk service_dt:mmddyy10.;
	  format service_dt mmddyy10.;
      cards;
     001 04/01/2014 
     001 01/01/2014 
     001 01/15/2014 
     001 03/01/2014 
     001 03/03/2014 
     001 04/15/2014 
     002 05/1/2014 
     002 10/1/2014 
     ;
run;

proc sort data= have out=_have ;
by person_sk service_dt;
run;

data want;
set _have;
by person_sk;
retain t;
if first.person_sk then do; t=service_dt;flag=1;end;
else do;flag= intck('days',t,service_dt)>30;
if flag then t=service_dt;
end;
drop t;
run;

View solution in original post

5 REPLIES 5
novinosrin
Tourmaline | Level 20

why is the 2nd record zero

    002 05/1/2014 1
     002 10/1/2014  0

 

10/1/2014 and 05/1/2014 are 153 days apart and that's greater than 30 plus the immediate record after 30 days?

skavyasindhu
Fluorite | Level 6

You are right. Sorry about that. I just edited.

novinosrin
Tourmaline | Level 20
data have;

      input person_sk service_dt:mmddyy10.;
	  format service_dt mmddyy10.;
      cards;
     001 04/01/2014 
     001 01/01/2014 
     001 01/15/2014 
     001 03/01/2014 
     001 03/03/2014 
     001 04/15/2014 
     002 05/1/2014 
     002 10/1/2014 
     ;
run;

proc sort data= have out=_have ;
by person_sk service_dt;
run;

data want;
set _have;
by person_sk;
retain t;
if first.person_sk then do; t=service_dt;flag=1;end;
else do;flag= intck('days',t,service_dt)>30;
if flag then t=service_dt;
end;
drop t;
run;
skavyasindhu
Fluorite | Level 6

This worked!! Thank you so much, i really appreciate your help.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 1798 views
  • 1 like
  • 3 in conversation