Hello all! I saw a few forums that were somewhat similar to this but did not answer this exact question, and have tried searching online to no avail, so I appreciate all possible help with this question. Basically, I want to know if it possible to add multiple recode commands when generating a new variable?

Here is what I would like to do.

Code:
gen farminglivestock2=.
    replace farminglivestock2=2 if q12a>0 & q12a<10
    replace farminglivestock2=2 if q12b>0 & q12b<10 
    label variable farminglivestock2 "Farming/ Tending Livestock"
    label define farminglivestock2 2 "Yes"
    label value farminglivestock2 farminglivestock2
Basically, when I run the gen code individually (meaning with JUST "replace farminglivestock2=2 if q12a>0 & q12a<10" or "replace farminglivestock2=2 if q12b>0 & q12b<10") it works correctly and I get the total number of people I need represented.

But I need to account for both q12a and q12b in my command. I tried to use the replace code "replace farminglivestock2=2 if q12a>0 & q12a<10 & q12b>0 & q12b<10" and "replace farminglivestock2=2 if q12a>0 & q12a<10 | q12b>0 & q12b<10" but each time it did not show the full amount of people I need (it basically did not include questions which had a value over 1 and less than 10 for both q12a and q12b).

q12a q12b

0 1



1 0


1 2 --> when I try to run both codes, it drops the 3 times when q12a and q12b both have values over 1 and less than 10, as seen here


So Is there a way to, like the example, be able to individually run the replace statements so that no variables are dropped? Or, is there a way to ensure that when there is a situation where both q12a and q12b have a value which meets the criteria, it is not dropped? I hope this makes sense!

For reference, I am using Stata 15.0! And sorry in advance for not using dataex (this is my first time posting so I am still trying to work things out). I installed it but the example set it generated did not include the example I wanted to show! If there are also suggestions on how to change the range of the example set, I would appreciate advice on that as well!