Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: RE: use dummy variable for nonmissing data


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: RE: use dummy variable for nonmissing data
Date   Sun, 16 Jan 2011 09:12:37 +0000

Your solution sounds correct in principle but comment on your practice
is difficult without any details at all on precisely how you created
your -nonmiss- and what you mean by "doesn't seem to work".

-egen, count()- counts non-missings and you can do that -by:-.

Nick

On Sat, Jan 15, 2011 at 8:10 PM, Rainald Borck
<Rainald.Borck@uni-passau.de> wrote:

> sorry, probably I didn't explain myself well. I know Stata can't do anything with missing values. The question is this: say I have individuals from Germany in 1990 who all have missings in some variable y and I have created the dummy variable _IcouXyea_GER_1990.  When I leave this variable in a regression of, say y on all the country-year dummies, Stata will drop it because all individuals from Germany in 1990 have missing y and all those who have nonmissing have a 0 in _IcouXyea_GER_1990. So I want to tell Stata to use only those _IcouXyea_country_year where there are individuals in the country and year with nonmissing values. This would be convenient (rather than manually adjusting the output for all dropped dummies).
>
> I tried by creating a variable nonmiss with values equal to 0 if there all individuals in a country in one year have missing values and 1 otherwise, and then
>
> preserve
>
> drop if nonmiss==0
>
> xi. i.country*i.year, noomit
>
> reg y var1  _IcouXyea*
>
> restore
>
> but this doesn't seem to work (neither without noomit).

>>>> Nick Cox  14.01.11 17.01 Uhr >>>

> This is just part of the default behaviour. Stata can't do anything statistical if values are missing and it ignores such observations. What do you think it could possibly do with them?

Rainald Borck

> I have survey data for individuals from several countries and years like this
>
> id country year var1 var2
> 1 A 1900 1 2
> ...
> 200 B 1900 3 .
> ...
>
>
>
> I have created country_year dummies using
> xi i.country*i.year, noomit
>
> Now I want to tell Stata to temporarily drop (or not use) the variable _IcouXyea_country_year if that country does not have observations for that year (i.e. the variable is missing for all individuals from that country and particular year). Can anyone help?

*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index