I am trying to put together some output displaying all subjects in the database with their medications and adverse events side by side, e.g. Subj, Med, AE. I need to use a join to pull the data from the CM and AE tables so I used the SUBJID in a left join (thinking this is correct).
The problem is that in the output, I am getting a mashup of every med lnked with every AE for each subject, which appears to be a cartesian join and not what I was expecting in the output.
The code is below, any suggestions in correcting this? I've plyed around with various other joins that Enterprise Guide allows but all seem to come up with a massive cartesian output.
PROC SQL;
CREATE TABLE SASUSER.QUERY_FOR_CM_SAS7BDAT_0002 AS
SELECT t1.SUBJID,
t1.CMTRT,
t2.AETRT
FROM EC100045.cm AS t1 LEFT JOIN EC100047.ae AS t2 ON (t1.SUBJID = t2.SUBJID)
WHERE t1.SUBJID = '201-008' AND t1.CMTRT NOT = '' AND t2.AETRT NOT = ''
ORDER BY t1.SUBJID, t1.CMTRT;
QUIT;
... View more