Here, we see the binning transformation for congestive heart failure diagnoses. First, we initialize the new column, Chf_dx, as an integer using an ALTER TABLE statement. The DEFAULT 0 statement means that all rows are initialized to be zero. Next, we set the column equal to 1 if and only if there is a code corresponding to CHF in the Pri_dx_icd column or the Sec_dx_icd column:
sqlite> ALTER TABLE MORT_FINAL_2 ADD COLUMN Chf_dx INTEGER DEFAULT 0;
sqlite> UPDATE MORT_FINAL_2 SET Chf_dx = 1
WHERE Pri_dx_icd = 'I50.9' OR Sec_dx_icd = 'I50.9';