Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
From | Nick Cox <n.j.cox@durham.ac.uk> |
To | "'statalist@hsphsun2.harvard.edu'" <statalist@hsphsun2.harvard.edu> |
Subject | RE: st: Missing value= Help with gen command. |
Date | Thu, 5 May 2011 15:15:52 +0100 |
This sounds to me like gen byte dumab = (cond(missing(a), 0, a) + cond(missing(b), 0, b)) > 0 As Rich Goldstein pointed out, (cond(missing(a), 0, a) + cond(missing(b), 0, b)) is what -egen, rowtotal()- does Nick n.j.cox@durham.ac.uk Oliver Jones gen sum_of_a_b = A + B gen byte dumab = (sum_of_a_b > 0) | (sum_of_a_b == .) Am 05.05.2011 14:38, schrieb vikramfinavker: > I am trying to generate new variable which is sum of A and B. i used: > > gen dumab=0 > > replace dumab=1 if A+B>0 > > however my problem is that where A has value and B has missing value (.) it > gives me answer (.) but instead i want 1. * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/