If the data has overlap in the group levels then it is not a coding issue but rather it is inherent in the data itself. You could add additional conditions as in:
replace mitypes = 2 if (mi_cas_da == 1 & somevar==somevalue)
so that both conditions must be TRUE in order to be assigned to level 2. But I understand that the data may have overlap in the groups (from reading your post). Is there a way to be more specific with the criteria that define the various levels of your variable?