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

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

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26
proc sort data=have out=want nodupkey;
    by id status eventdate;
run;
--
Paige Miller

View solution in original post

3 REPLIES 3
novinosrin
Tourmaline | Level 20

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;
sks521
Quartz | Level 8

Fabulous! it worked absolutely fine.

 

Really appreciate!

PaigeMiller
Diamond | Level 26
proc sort data=have out=want nodupkey;
    by id status eventdate;
run;
--
Paige Miller

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!

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 3 replies
  • 1027 views
  • 2 likes
  • 3 in conversation