Hi there,
I have below conmed data which is collected on different dates and i want to calculate the total number of days taken medications from first date to last date per visit.
Subject 16-001 is collected different conmeds on multiple dates hence intermediate dates should not be consider e.g. 1st conmed taken from 17 to 21 may while 2nd 17 to 27 May so 18 to 21 already covered in 2nd record, this should not be re-calculated in number of days. 17-May to 27-May i.e. total number of days are 11 days. for subject 30-003 at WEEK 4 collected on 24 and 29 Jun only so Total number of days will be 2 as conmed not taken from 25 to 28 Jun date.
SUBJID AVISITN AVISIT ASTDT ENDT
16-001 2 BASELINE 17-May-20 21-May-20
16-001 2 BASELINE 17-May-20 27-May-20
16-001 2 BASELINE 21-May-20 21-May-20
16-001 2 BASELINE 22-May-20 22-May-20
16-001 2 BASELINE 23-May-20 23-May-20
16-001 2 BASELINE 23-May-20 27-May-20
16-001 2 BASELINE 24-May-20 24-May-20
16-001 2 BASELINE 25-May-20 26-May-20
30-003 2 BASELINE 27-May-20 27-May-20
30-003 3 WEEK 4 24-Jun-20 24-Jun-20
30-003 3 WEEK 4 29-Jun-20 29-Jun-20
40-008 2 BASELINE 13-Jan-20 13-Jan-20
40-008 2 BASELINE 15-Jan-20 15-Jan-20
40-008 2 BASELINE 17-Jan-20 17-Jan-20
40-008 2 BASELINE 17-Jan-20 17-Jan-20
40-008 2 BASELINE 18-Jan-20 18-Jan-20
40-008 2 BASELINE 19-Jan-20 19-Jan-20
40-008 3 WEEK 4 14-Feb-20 14-Feb-20
Thanks,
Rohit
Run next code and add any other step to count days per SUBJID.
You may add any other categorial variables if need, like AVISITN etc.
data temp;
set have;
do date=astdt to endt; output; end;
keep subjID avisitn avisit date;
format date date11.;
run;
proc sort data=temp out=temp1 NODUPKEY;
by subjid date /* avisitn avisit ??? */;
run;
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: