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 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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