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

Hello,

I need some help with the following code. The first five columns are vaccinations given, and the last column is a concatenation of ID and date of visit. If someone is given the same vaccine on the same day it shouldn't count twice. Line 1 and line 4 both have Dtap observations, for the same ID/date. I can't delete the 4th observation because there's also a new vaccination there. If a patient has the same vaccine tagged as "1" on the same date, is there any way I can turn that second occurrence to "0"?

 

data SAMPLE;
  infile datalines dsd truncover;
  input DTAP:32. polio:32. MMR:32. HiB:32. HepB:32. ID_VaxDate:$19.;
datalines;
1 1 0 0 1 154548,2015-04-30
0 0 0 0 0 154548,2015-04-30
0 0 0 1 0 154548,2015-04-30
1 0 1 0 0 154548,2015-04-30
0 0 0 0 1 154548,2018-09-04

Thank you!

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

Why can't you just reduce it to one observation per id*date?

 

proc summary nway data=sample;
  class ID_VaxDate;
  var DTAP polio MMR HiB HepB ;
  output out=want max= ;
run;

 

 

 

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

Why can't you just reduce it to one observation per id*date?

 

proc summary nway data=sample;
  class ID_VaxDate;
  var DTAP polio MMR HiB HepB ;
  output out=want max= ;
run;

 

 

 

Amenon
Calcite | Level 5

Thank you that works!! I thought it had to be a simple solution but I just couldn't figure out the right googleable terms. 

Ready to join fellow brilliant minds for the SAS Hackathon?

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!
Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 2 replies
  • 387 views
  • 1 like
  • 2 in conversation