----Hugh wrote:
> I have pairs of variables (i.e. p1 q1, p2 q2, etc. The final pair is
> pfinal and qfinal). All I want is that when either p`i' or q`i' has a
> blank, it takes the value of 0 while the other retains its value. When
> both p and q are blank, I dont want anything to be changed.
Hugh:
It is easier if the final pair also adheres to the format pnumber, qnumber.
Than the code looks like this:
forvalues 1 = 1/3 {
replace p`i' = 0 if p`i' == . & q`i' != .
replace q`i' = 0 if q`i' == . & p`i' != .
}
Otherwise it looks like this:
local stub "1 2 final"
foreach i of local stub {
replace p`i' = 0 if p`i' == . & q`i' != .
replace q`i' = 0 if q`i' == . & p`i' != .
}
HTH,
Maarten
*
* 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/