Dear All,
I have the following dataset:
I generated min and max using:
However, when the first number is negative (fifth row, for instance), I cannot obtain the full number (I will convert later the string to number) because of the -. Is there any way I can solve this problem and having -1.7 rather than -1. I am appending together multiple files and it is tedious to do this manually. By the way, I cannot even understand why I should write
rather than
In the latter case I got just the integer and the decimal separator.
Thanks in advance for your help.
Dario
I have the following dataset:
Code:
* Example generated by -dataex-. For more info, type help dataex clear input str17 country str3 iso str5 region float score byte rank str10 interval float year str3 min str4 max "Argentina" "ARG" "AME" 3.5 57 "2.9 - 4.4" 2001 "2.9" " 4.4" "Australia" "AUS" "AP" 8.5 11 "6.8 - 9.4" 2001 "6.8" " 9.4" "Austria" "AUT" "WE/EU" 7.8 15 "7.2 - 8.7" 2001 "7.2" " 8.7" "Azerbaijan" "AZE" "ECA" 2 84 "1.8 - 2.2" 2001 "1.8" " 2.2" "Bangladesh" "BGD" "AP" .4 91 "-1.7 - 3.8" 2001 "-1." "- 3." "Belgium" "BEL" "WE/EU" 6.6 24 "5.7 - 7.6" 2001 "5.7" " 7.6" "Bolivia" "BOL" "AME" 2 84 "1.5 - 3.0" 2001 "1.5" " 3.0" "Botswana" "BWA" "SSA" 6 26 "5.6 - 6.6" 2001 "5.6" " 6.6" end
Code:
gen min=substr(interval, 1,3) gen max=substr(interval, 6,4)
Code:
gen max=substr(interval, 6,4)
Code:
gen max=substr(interval, 6,3)
Thanks in advance for your help.
Dario

Comment