Hi,
Consider the following dataset:
I want to convert the grade variable into numeric.
First I recode the "NULL" to ".a".
But my conversion still fails. And when I use the force option, everything becomes lost.
grade: contains nonnumeric characters; newvar generated as byte
(18 missing values generated)
What seems to be the issue?
Consider the following dataset:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str13 grade float id "-1.565247655" 1 "-5.57115221" 2 "-6.743679047" 3 "0.7140107751" 4 "-.5790126324" 5 "0.4549108744" 6 "-.5358353257" 7 "0.8597764373" 8 "0.5713045597" 9 "1.07125771" 10 "-5.094827175" 11 "0.8716378212" 12 "NULL" 13 "-5.167676449" 14 "-0.8569977283" 15 "-11.75496864" 16 "-0.5923922658" 17 "-0.9578948617" 18 "-1.828699946" 19 end
First I recode the "NULL" to ".a".
Code:
replace grade=".a" if grade=="NULL" destring grade, gen(newvar) force
grade: contains nonnumeric characters; newvar generated as byte
(18 missing values generated)
What seems to be the issue?
Comment