You could use a UNION or UNION ALL statement to append the tables using PROC SQL. The difference between UNION and UNION ALL is that UNION ALL will return duplicates if they exist. In the following example, I've used UNION ALL. Note I haven't checked to make sure that the number of columns and column names in both SELECT statements are the same (they must be the same). Code is untested. PROC SQL; CREATE TABLE tempHAC AS SELECT 'HAC1' AS Measure, dat.Cal_Yr, dat.Cal_Mo_Order, COUNT(acc.HospitalAccountID) AS HaC_Count FROM dwaprv.FACT_HospitalAccount AS acc, dwaprv.FACT_HospitalAccountDiagnosis AS Diag, dwaprv.DIM_Date AS dat, dwaprv.DIM_Diagnosis AS ddiag where acc.HospitalAccountID = diag.HospitalAccountID and acc.DateDischargeKey = dat.DateKey and diag.DiagnosisKey = ddiag.DiagnosisKey and diag.Line ne 1 and diag.DX_POA_YNU IN ("N","U") and acc.DateDischargeKey >= &BegDate AND acc.DateDischargeKey <= &EndDate AND ddiag.ICD9_Code IN ( SELECT hacd.DX_Code FROM dwaprv.REF_HACDiagnosis AS hacd WHERE hacd.HAC_Description = 'HAC1')/*--('998.4','998.7')*/ AND EncounterTypeKey IN (1, 12, 13, 14, 15) GROUP BY dat.Cal_Yr, dat.Cal_Mo_Order UNION ALL SELECT 'HAC2' AS Measure, dat.Cal_Yr, dat.Cal_Mo_Order, COUNT(acc.HospitalAccountID) AS HAC_Count FROM dwaprv.FACT_HospitalAccount AS acc, dwaprv.FACT_HospitalAccountDiagnosis AS Diag, dwaprv.DIM_Date AS dat, dwaprv.DIM_Diagnosis AS ddiag where acc.HospitalAccountID = diag.HospitalAccountID and acc.DateDischargeKey = dat.DateKey and diag.DiagnosisKey = ddiag.DiagnosisKey and diag.Line ne 1 AND diag.DX_POA_YNU IN ('N','U') AND acc.DateDischargeKey >= &BegDate AND acc.DateDischargeKey <= &EndDate AND ddiag.ICD9_Code IN ( SELECT hacd.DX_Code FROM dwaprv.REF_HACDiagnosis AS hacd WHERE hacd.HAC_Description = 'HAC2') /*--('999.1')*/ AND EncounterTypeKey IN (1, 12, 13, 14, 15) GROUP BY dat.Cal_Yr, dat.Cal_Mo_Order ORDER BY dat.Cal_Yr, dat.Cal_Mo_Order ; quit;
... View more