Hi Statalist.

I have found that after creating a new categorical variable that not all categories appear (see below), requiring me to rerun code for the missing category. The code creates different religious pairings within couples (in which the respondent (religb) is coded differently to their partner (p_religb). The code separates three 'levels': 2 same relig, 2 different, 1 relig/1 not).

To reduce the long lists of value labels in the code (only present in the first set of code - hereafter replaced by Prot1, Prot2, Other religion.
Code:
gen faith = 1 if religb == p_religb & religb == 2070 // same Catholic    
replace faith = 2 if religb == p_religb & inlist(religb, 2010, 2030, 2050, 2170, 2250, 2270, 2330, 2800)  // same Prot1 (hereafter listed as prot1)
replace faith = 3 if religb == p_religb & inlist(religb, 2110, 2130, 2150, 2310, 2400)  // same Prot2 (hereafter listed as prot2)
replace faith = 4 if religb == p_religb & inlist(religb, 1000, 3000, 4000, 5000, 6000 // same 'Other' relig (hereafter listed as relOther)

replace faith = 5 if religb != p_religb & prot1 & prot1_p // diff Prot1
replace faith = 6 if religb != p_religb & inrange(religb, 2010, 2800) & inrange(p_religb, 2010, 2800) // diff Prot = (prot1+prot2)
replace faith = 7 if religb != p_religb & (religb == 2070 | p_religb == 2070) & (prot1 | prot1_p) // Cath + Prot1
replace faith = 8 if religb != p_religb & (religb == 2070 | p_religb == 2070) & inrange(religb, 2010, 2800) & inrange(p_religb, 2010, 2800) // Cath + Prot

replace faith = 9 if religb != p_religb & (religb == 2070 | p_religb == 2070) & (religb == 7000 | p_religb == 7000) // Cath + No relig
replace faith = 10 if religb != p_religb & (prot1 | prot1_p) & (religb == 7000 | p_religb == 7000) // Prot1 + No relig
replace faith = 11 if religb != p_religb & (relOther | relOther_p) & (religb == 7000 | p_religb == 7000) // Other relig + No relig
replace faith = 12 if religb == p_religb & religb == 7000 & import == 1 & attend == 1 // both 'No relig'
Help identifying the problem appreciated.
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input int(religb p_religb) float faith
2070 2070  1
2330 2010  6
2310 2310 3
7000 7000 12
2330 2330  2
2010 2010  2
7000 2330 10
7000 7000 12
2070 7000  9
2070 2110  8
2070 2330  7
2070 2070  1
2330 2010  6
2400 2400 3
1000 7000 11
2070 2010  7
1000 1000  4
3000 3000  4
2330 2010  5
2050 2330  5
2010 2400  6
end
[ATTACH=CONFIG]temp_19403_1597819184194_450[/ATTACH]