Hi SAS communities, I am currently trying to match merge 4 data sets into one. There should only be 1 observations per person, which includes the most recent visit. The data set should include people that have data in the 3 data sets: Contact, Demog, and Vitals. Also, most of the people in those data sets have not died and will not have a matching observation in the NDI data set. Conversely, most of the people in the ‘NDI’ data set are not in our cohort (so we don’t want to include those observations). Therefore, when performing a match-merge with the ‘NDI’ data set, the observations from the ‘NDI’ data set which don’t have a matching row in the other 3 data sets should not be included. DATA HYPANL.HYPANALYSIS2;
RETAIN SSN StateCd GenderCd EthCd RaceCd AgeAtVisit SBP DBP WtLb HypRelDeathInd;
MERGE WORK.VitalLast (IN = InVitalLast)
HypTabs.NDI (IN = InNDI)
HypTabs.Contact (IN = InContact)
HypTabs.DEMOG (IN = InDemog);
BY SSN;
IF InContact = 1
AND InVitalLast = 1
AND InDemog = 1;
/* IF LAST.SSN; */
AgeAtVisit=yrdif(BirthDt, VisitDt, 'AGE');
FORMAT BirthDt YYMMDD10.
AgeAtVisit 4.0;
/* IF InNDI = 0 THEN HypRelDeathInd = 0; */
/* IF InNDI = . THEN HypRelDeathInd = 0; */
/* ELSE IF InNDI = 0 THEN HypRelDeathInd = 0; */
/* ELSE IF InNDI = 1 THEN HypRelDeathInd = 1; */
IF HypRelDeathInd = . THEN HypRelDeathInd = 0;
/* ELSE IF HypRelDeathInd = 0 THEN HypRelDeathInd = 0; */
/* ELSE HypRelDeathInd = 1; */
FORMAT HypRelDeathInd IndVbl.
StateCd $StateCd.;
FORMAT HypRelDeathInd IndVbl. StateCd $StateCd.;
DROP VisitDt HtIn DeathDt ICD10 CODCd City Inits ZipCd EthRaceCd BirthDt;
RUN;
PROC PRINT DATA = HYPANL.HYPANALYSIS2;
RUN; I have tried several IF THEN statements, but I still get 566 observations. However, with some IF THEN statements I get 11 observations that have a 'Yes' in the 'HypRelDeathInd' variable, and with other IF THEN statements I get 16. Either way, I still end up with 566 observations, which means there are 7 missing observations. Thanks in advance for any help/tips!
... View more