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!!
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;
this link should have the solution you are asking for.
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?
You are right. Sorry about that. I just edited.
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;
This worked!! Thank you so much, i really appreciate your help.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.