My input dataset looks as follows:
DRUG Table
DRUG_CD PARENT_DRUG_CD
DRG_1 DRG_5
DRG_2 DRG_5
DRG_3 DRG_4
DRG_4 --
DRG_5 DRG_6
DRG_6 --
I need to build a dataset with only those DRUGS (and all the attributes of this DRUGS) who does not have a parent anymore and an extra column (CHD_DRUG_CD) which contains the lowest level of DRUG_CD.
Resulting DRUG Table
DRUG_CD CHD_DRUG_CD
DRG_6 DRG_1
DRG_6 DRG_2
DRG_6 DRG_5
DRG_4 DRG_3