Sorry for the delayed reply to your question.
genderp==2 indicates female sex, so you are correct that you need to replace female=1 if genderp==2.
To find missing values in your 2 X 2 table, enter the code: tab genderp female, missing. In this survey, a response of 9 indicates a missing value. In Stata, . indicates a missing value. You need to replace the values with a 9 and . as missing in the new female variable. To do this, enter: replace female=. if genderp==9|genderp==. (translation: replace female as missing if genderp is 9 or missing)