Hi Stata community,
I am struggeling with splitting names under various conditions.
I have a name variable which I want to split into a mainname and a subname.
The classification is as follows: the part after the last comma is the subname but only if this part does not include "#".
In case there is a "#" after the last comma and there are two words after the "#", the part after the "#" presents the subname.
If there are more or less than two words, the conclusion is that there is no subname at all.
The mainname should be basically the inital name without the subname. If there is no subname, the mainname is the whole name.
So far I tried to work with split, parse but I couldn't allow for all the conditions with this command.
All help is much appreciated.
Many thanks,
Sandra
I am struggeling with splitting names under various conditions.
I have a name variable which I want to split into a mainname and a subname.
The classification is as follows: the part after the last comma is the subname but only if this part does not include "#".
In case there is a "#" after the last comma and there are two words after the "#", the part after the "#" presents the subname.
If there are more or less than two words, the conclusion is that there is no subname at all.
The mainname should be basically the inital name without the subname. If there is no subname, the mainname is the whole name.
So far I tried to work with split, parse but I couldn't allow for all the conditions with this command.
All help is much appreciated.
Many thanks,
Sandra
Comment