First principles solution: 
gen IB = 0 
foreach v of var stove refri house { 
	replace IB = IB + !missing(`v') 
} 
Quick and dirty: 
egen IB = rownonmiss(stove refri house) 
Nick
[email protected] 
Leonor Saravia
I'm learning how to make some programs in Stata and I�m having
problems in how I could tell Stata to do an indicator I need.
I'm working with the data base for different countries of
latinamerica. In almost all of them I have the same dummy variables
which tell me if the interviwed household has or not a particular good
in the house, but there are cases where the country didn't ask the
household about having this goods, so in this cases I have the
variable with missing values.
The dummy variables, which distinguish the goods being studied, are:
'stove' (1 if has a stove; 0 other way) ; 'refri' (1 if it has a
refrigerator ; 0 other way) ; 'house' (1 if it's the owner of the
house ; 0 other way) .
My problem is that I'd like to perform the next indicator:
gen IB =  (stove + refri + house)/q
where 'q'  is a number between 1 and 3, depending how many variables
had values different from missing.
The data looks like this (and I agregate the value - in fraction - for
the IB that I would like to create):
id_household    stove    refri   house      IB
1                       1          1       0         2/3
2                        0         .        1         1/2
3                        .         .         0         0/1
I'd appreciate very much if you could help me, because I 'don't know
how I could tell Stata to do this.
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/