Code:
* Example generated by -dataex-. For more info, type help dataex clear input str12 Source float(sheep_goat cattle chicken virulence_combined) "chicken" . . . 0 "cattle" . . . 1 "cattle" . . . 1 "sheep_goat" . . . 1 "sheep_goat" . . . 2 "sheep_goat" . . . 0 "sheep_goat" . . . 1 "chicken" . . . 0 "sheep_goat" . . . 2 "sheep_goat" . . . 1 end label values sheep_goat virulencel label values cattle virulencel label values chicken virulencel
I am trying to create a variable that categorizes the number of virulence genes for a particular source. For example, if the value of source is 'sheep_goat' as in line 5, I would like the sheep_goat variable to be 1 based on the variable virulence_combined. The sheep_goat variable will be missing when the source is not sheep_goat. I am having a hard time thinking about how to tell Stata to change the value of one variable (sheep_goat) based on the value of another variable (virulence_combined) if the value of another variable (Source = "sheep_goat") is the same as the name as that variable (sheep_goat). I hope this makes sense.
Comment