Hi,
I'm aware this potentially may be quite trivial so apologies in advance. I am running the below command, I would like it to be more efficient. I'm familiar with setting a global macro of all the sport and then running a loop but this creates a A-Z variables for each sport which I do not want...only want A to correspond to Football, B to Cricket ...
gen A=0
replace A=1 if sport=="Football"
gen B=0
replace B=1 if sport=="Cricket"
gen C=0
replace C=1 if sport=="Rugby"
....
gen Z=0
replace Z=1 if sport=="Snooker"
Any assistance would be much appreciated! Many thanks in advance.
I'm aware this potentially may be quite trivial so apologies in advance. I am running the below command, I would like it to be more efficient. I'm familiar with setting a global macro of all the sport and then running a loop but this creates a A-Z variables for each sport which I do not want...only want A to correspond to Football, B to Cricket ...
gen A=0
replace A=1 if sport=="Football"
gen B=0
replace B=1 if sport=="Cricket"
gen C=0
replace C=1 if sport=="Rugby"
....
gen Z=0
replace Z=1 if sport=="Snooker"
Any assistance would be much appreciated! Many thanks in advance.
Comment