Dear all,
I would like to construct a numeric variables from the string variable that contains letters and numbers combined. The structure of the variable does not allow me to use
option. The string variables ("string") and the variable I want to create ("numeric") are as follows:
...
Basically, I do not want RS part of the string variable.
I tried using the following command:
[QUOTE]
gen str1 Numeric = substr("String",3,.)
destring Numeric, replace
/QUOTE]
However the first command of the two does not work. I usually get just one digit extracted (the third digit-1 and 0 respectively) instead of all 6.
Any help would be much appreciated!
Thank you!
I would like to construct a numeric variables from the string variable that contains letters and numbers combined. The structure of the variable does not allow me to use
destring, replace
String Numeric
RS123456 123456
RS098766 098766
RS123456 123456
RS098766 098766
Basically, I do not want RS part of the string variable.
I tried using the following command:
[QUOTE]
gen str1 Numeric = substr("String",3,.)
destring Numeric, replace
/QUOTE]
However the first command of the two does not work. I usually get just one digit extracted (the third digit-1 and 0 respectively) instead of all 6.
Any help would be much appreciated!
Thank you!
Comment