A couple of days ago I showed how you can use logical operators inside arithmetic expressions. The point of that post was that if you had three variables, called say _var1, _var2 and _var3, then you could build another variable, call it _var4, that counted row-wise their non-zero instances, like so:
gen _var4=(_var1!=0)+(_var2!=0)+(_var3!=0)
This was actually spun [...]