Please explain further. Why are those two records the only output? What is the logic that keeps those two lines and not the others?
I would recommend you go back and check on the task you were given.
It is certainly possible for a patient to have more than one adverse event on the same day. It would be unusual to be allowed to report only one.
It is unusual for a patient to report the same adverse event multiple times on the same day. If a patient reports 3 headaches on the same day, they would usually be treated as a single headache.
This does not address my earlier question: "Why are those two records the only output? What is the logic that keeps those two lines and not the others?"
Specifically, why are there no output records for Patid 1?
Without entering, is the query logic or not, I assume that next code may give you the requested result:
proc sort data=have out=temp nodupkey;
by patid date advevent;
run;
data want;
set temp;
by patid date advevent;;
if not (first.date and last.date);
run;
Here is an SQL solution:
proc sql;
create table want as
select distinct Patid, advevent,date from have
group by Patid, date
having count(distinct advevent)>1;
quit;
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.