I have a table with patient Id, treatment type, date of first prescription and date of last prescription. I want to create a new column (variable) which will return 1 if the first prescription date plus 30 days overlaps with the last prescription date, otherwise assign it a value of 0. i tried using the retain function but no results. Can you please help me?
I now noticed that once there is only 1 prescription and no last prescription the overlap is assigned as 1, is there a way to overcome that?
thank you
my code:
data overlap ;
set Rxfinal ;
by id date ;
lagtrt= lag(treatment);
if first.id then lagtrt=treatment;
if not first.id then lagtrt=0 ;
switch = intnx("DAY", date, 30) >= lastdate;
run ;
The 2025 SAS Hackathon has begun!
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.