I have a string variable CODEX which has the underlying cause of death coded first, and any secondary causes of death following. The cause of deaths codes are from the ICD-10 codes (International Classification for Disease). All the causes of death are separated by spaces or commas.

I am attempting to separate this string variable CODEX into separate cause of death variables DEATH1, DEATH2 etc. Any suggestions for potential codes for this would be greatly appreciated as I am not too sure how to approach this issue.