Dear everyone,

I hope you are doing well.
I exported a document from Excel into Stata.
One of the column was in % in Excel. When exporting it on Stata, it has now a mix with % and decimal (0.33 for 33%).
I am trying to convert each % to a decimal number.

Code:
stake
1
66%
33%
.67
.33
.33
.67
I did the following code:

Code:
gen x =  strpos(stake, "%") > 0
gen new_stake = stake if x == 1
replace new_stake = subinstr(new_stake, "%", "",.)
encode new_stake, generate(new_stake2)
replace new_stake2 = (new_stake2/100)
destring new_stake2, replace
replace stake = "." if x == 1
encode stake, generate(stake2)
replace stake2 = new_stake2 if stake == .
Unfortunately, it says that I cannot perform the last line as it is a type mismatch. New_stake2 is in double format and stake2 long format.
Is there any way to do it with less code or change directly the percentage in my stake column directly?

Thank you very much !