Hello all,
I have a variable, s4mainocc, which is constructed in the following way (I provide a number of examples below). The s4mainocc variable is a string variable.
Now I'd like to separate the occupational code (the first four digits - note ALL occupations are four digits) from the label into two separate variables. This example https://www.statalist.org/forums/forum/general-stata-discussion/general/1612510-split-a-string-variable-into-character-and-numeric-parts seemed to be exactly what I was looking for, so I tried the following:
however I received the following error code:
I have a variable, s4mainocc, which is constructed in the following way (I provide a number of examples below). The s4mainocc variable is a string variable.
Code:
2412. Personnel and careers professionals 3433. Bookeepers 4115. Secretaries
Code:
gen numeric = substr(s4mainocc, 4, 4)
Code:
type mismatch r(109);
Comment