Hi everyone,
I have variable Gender in my data. I run encode command to convert "Gender" to numeric variable.
encode Gender, Gen(sex)
input str1 Gender
"M"
"M"
"M"
"M"
"M"
"M"
"M"
"M"
"M"
"M"
"M"
"M"
"M"
"M"
"M"
"M"
"M"
"M"
"M"
"M"
"M"
"F"
"M"
"M"
"M"
"M"
"F"
"F"
as you can see based on (dataex below ) it is not string anymore but when I brows my data it shows 0 for "M" and F for "F". I can't change F to 1. When I use replace command it gives me dismatch error. Could you please help me find the problem? why F is still shown F after encode??
* Example generated by -dataex-.
clear
input str1 Gender long sex
"M" 0
"M" 0
"M" 0
"M" 0
"M" 0
"M" 0
"M" 0
"M" 0
"M" 0
"M" 0
"M" 0
"M" 0
"M" 0
"M" 0
"M" 0
"M" 0
"M" 0
"M" 0
"M" 0
"M" 0
"M" 0
"F" 1
"M" 0
"M" 0
"M" 0
"M" 0
"F" 1
"F" 1
I have variable Gender in my data. I run encode command to convert "Gender" to numeric variable.
encode Gender, Gen(sex)
input str1 Gender
"M"
"M"
"M"
"M"
"M"
"M"
"M"
"M"
"M"
"M"
"M"
"M"
"M"
"M"
"M"
"M"
"M"
"M"
"M"
"M"
"M"
"F"
"M"
"M"
"M"
"M"
"F"
"F"
as you can see based on (dataex below ) it is not string anymore but when I brows my data it shows 0 for "M" and F for "F". I can't change F to 1. When I use replace command it gives me dismatch error. Could you please help me find the problem? why F is still shown F after encode??
* Example generated by -dataex-.
clear
input str1 Gender long sex
"M" 0
"M" 0
"M" 0
"M" 0
"M" 0
"M" 0
"M" 0
"M" 0
"M" 0
"M" 0
"M" 0
"M" 0
"M" 0
"M" 0
"M" 0
"M" 0
"M" 0
"M" 0
"M" 0
"M" 0
"M" 0
"F" 1
"M" 0
"M" 0
"M" 0
"M" 0
"F" 1
"F" 1
Comment