Hi I am trying to destring a variable. Then replace those variables with numbers eg
A = 1
B = 2
However I want the A and B to remain showing so as not to forget what 1 and 2 stand for. I found two ways how to do it. Are there any adv/disadv to any of the methods shown below
METHOD 1
Encode stringvariable, gen(encode_variable)
label list encode_variable
label define variable encode_variable “ 1 A, 2 B”
METHOD 2
Section B:
gen new_variable = real (string_variable)
replace new_variable = 1 if string_variable == “A”
label define string_variablelabel 1 “A”
label values new_variable string_variablelabel
Is this just multiple ways how to skin a cat?

(we live with 4 cats!!) !!
Comment