Query Set #4c – aggregating cardiac diagnoses using SUM

While binning is important for separating out individual diagnoses, in practice, we often want to group similar or near-identical diagnostic codes together as a single variable. Aggregating combines two or more binary variables into a single binary/numeric variable. Here, we aggregate all cardiac diagnostic codes in our dataset (CHF, hypertension, and angina are cardiac diseases) using the + operator. The result is a count of the number of total cardiac diagnoses for each of the five patients:

sqlite> ALTER TABLE MORT_FINAL_2 ADD COLUMN Num_cardiac_dx INTEGER;

sqlite> UPDATE MORT_FINAL_2 SET Num_cardiac_dx = Chf_dx + Htn_dx + Angina_dx;

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset