Hi Stata experts,
I'm having a problem with destring command when I run simple lines of code below. the variable industrystr2 is a string variable generate by substring the first two digit of the origrinal 4-digit industry code. But when I want to destring the 2-digit industry code back to numerical values, I have the '$ invalid name' error.
The thing is, there is no value "$" whatsoever in the string variable, nor the variable name has "$" character!
I have run the SAME codes countless times in Stata 13 or 14 without any problem. But when I do in Stata 16 this error keeps showing up with destring and very same error message. Is it a problem with Stata 16 or with my computer or the Stata software that I have? It's very inconvenient to switch computers (I have Stata 13 and 14 on other computers) just to run one simple destring command. I would really appreciate if you could help me resolve this once and for all.
Many thanks,
Jade
I'm having a problem with destring command when I run simple lines of code below. the variable industrystr2 is a string variable generate by substring the first two digit of the origrinal 4-digit industry code. But when I want to destring the 2-digit industry code back to numerical values, I have the '$ invalid name' error.
The thing is, there is no value "$" whatsoever in the string variable, nor the variable name has "$" character!
I have run the SAME codes countless times in Stata 13 or 14 without any problem. But when I do in Stata 16 this error keeps showing up with destring and very same error message. Is it a problem with Stata 16 or with my computer or the Stata software that I have? It's very inconvenient to switch computers (I have Stata 13 and 14 on other computers) just to run one simple destring command. I would really appreciate if you could help me resolve this once and for all.
Many thanks,
Jade
Code:
. g str4 industrystr4=string(industry,"%04.0f") . . g industrystr2 = substr(industrystr4, 1, 2) . . replace industrystr2 ="" if industrystr2=="." (3,242,563 real changes made) . . destring industrystr2, replace $ invalid name r(198); end of do-file r(198); .
Code:
. list industry industrystr4 industrystr2 in 1/10 +--------------------------------+ | industry indust~4 indus~r2 | |--------------------------------| 1. | . . | 2. | . . | 3. | . . | 4. | 2396 2396 23 | 5. | . . | |--------------------------------| 6. | 5610 5610 56 | 7. | . . | 8. | . . | 9. | . . | 10. | 111 0111 01 | +--------------------------------+
Comment