Missing Values & the Generation of New Variables

6 views
Skip to first unread message

Jia De Gedeon Lim

unread,
May 27, 2013, 11:31:00 PM5/27/13
to income-dynam...@googlegroups.com
Hey everyone,

I noticed that my Stata gives me a missing value when I generate a new variable that equals the sum of two other variables when the value of either one variable is missing.

E.g. from Ajay's solowhh_dataprep.do

arisredsload hh82/Deck 9.dta

gen vfarmasst = v9 + v10

collapse (sum) vfarmasst, by(v3)
rename v3 id1982
sort id1982
tempfile farmasst82
save `farmasst82'

Running the first part of the code (gen vfarmasst...) actually generates 6014 missing values but in some of these cases, for e.g., v9 is missing but v10 has a integer value. It is just the case that Stata, probably treating . as a infinite value (?) codes vfarmasst with a missing value as well.

Just thought I'd point this out 'cos I never realized that my Stata does this and I'm wondering if it's a problem that occurs only on a/my Macbook or it is a universal occurrence. Thanks!

Best,
Gedeon

Ajay Shenoy

unread,
May 28, 2013, 12:38:03 PM5/28/13
to income-dynam...@googlegroups.com
This is the issue Raj mentioned where it's better to use egen = rowtotal(), which will treat missing values as zeros (as long as at least one value in the varlist is not missing).  Which is what I should've done here...
-@

Jia De Gedeon Lim

unread,
May 28, 2013, 10:57:58 PM5/28/13
to income-dynam...@googlegroups.com
Oh i see. Thanks for the clarification Ajay!
Reply all
Reply to author
Forward
0 new messages