My variable «mystring» is a string variable that uses commas as decimal separator
Below is its list
----------------------- copy starting from the next line -----------------------
------------------ copy up to and including the previous line ------------------
Listed 7 out of 7 observations
I want to change this variable to numeric variables
I used the command below.
destring mystring, replace force ignore(",")
the results are
dataex
----------------------- copy starting from the next line -----------------------
------------------ copy up to and including the previous line ------------------
Listed 7 out of 7 observations
As you can see, the new numbers are the wrong number. For example, the first variable was supposed to be 9 or 8.5, but now it is written as 85 instead. Also, the last variable is supposed to be 12.896 or 13 ( if rounded). However, now I have a very big value, which is equal to 12896
Would you please give me a suggestion on how I can change this string variable to numeric while keeping the right amount of values?
Thank you, and looking forward to hearing from you
Below is its list
----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str6 mystring "8,5" "'" "" "8" "4" "0,4" "12,896" end
Listed 7 out of 7 observations
I want to change this variable to numeric variables
I used the command below.
destring mystring, replace force ignore(",")
the results are
dataex
----------------------- copy starting from the next line -----------------------
Code:
* Example generated by -dataex-. For more info, type help dataex clear input int mystring 85 . . 8 4 4 12896 end
Listed 7 out of 7 observations
As you can see, the new numbers are the wrong number. For example, the first variable was supposed to be 9 or 8.5, but now it is written as 85 instead. Also, the last variable is supposed to be 12.896 or 13 ( if rounded). However, now I have a very big value, which is equal to 12896
Would you please give me a suggestion on how I can change this string variable to numeric while keeping the right amount of values?
Thank you, and looking forward to hearing from you
Comment