Hi,
I got a complicated question;
The data I am handling is strangely formatted. Example below;
ID status EventDate Readcode
1 Intervention group 16/02/2016 XaF8d
1 Intervention group 16/02/2016 X78uk
1 Intervention group 16/02/2016 XaLIe
1 Intervention group 14/04/2016 XaFqt
1 Intervention group 14/04/2016 XaF8d
1 Intervention group 14/04/2016 X78uk
1 Intervention group 14/04/2016 4662
1 Intervention group 14/04/2016 4672
2 Control 14/04/2016 4662
2 Control 14/04/2016 4672
2 Control 05/05/2017 X77Wi
2 Control 05/05/2017 XaK8y
Where EventDate represent a visit to primary healthcare and each code represent some sort of investigation carried out on that date for respective ID. I want to create a data set with discrete visit per date for each id as below;
1 Intervention group 16/02/2016 XaF8d
1 Intervention group 14/04/2016 XaFqt
2 Control 14/04/2016 4662
2 Control 05/05/2017 X77Wi
The problem comes where multiple ids have similar EventDate where the system considers all similar dates as duplicates and deletes other ids with similar EventDate. I have tried Proc summary but it discards for example id 2 with similar dates as id 1 (14/04/2016 in this case) which is not what I want.
Can someone help please?
Thanks
proc sort data=have out=want nodupkey;
by id status eventdate;
run;
are you after this?
data have;
input ID status & $30. EventDate :ddmmyy10. Readcode $;
format eventdate ddmmyy10.;
cards;
1 Intervention group 16/02/2016 XaF8d
1 Intervention group 16/02/2016 X78uk
1 Intervention group 16/02/2016 XaLIe
1 Intervention group 14/04/2016 XaFqt
1 Intervention group 14/04/2016 XaF8d
1 Intervention group 14/04/2016 X78uk
1 Intervention group 14/04/2016 4662
1 Intervention group 14/04/2016 4672
2 Control 14/04/2016 4662
2 Control 14/04/2016 4672
2 Control 05/05/2017 X77Wi
2 Control 05/05/2017 XaK8y
;
proc sort data=have out=want nodupkey;
by id eventdate;
run;
Fabulous! it worked absolutely fine.
Really appreciate!
proc sort data=have out=want nodupkey;
by id status eventdate;
run;
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 the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.