Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: Missing values in -egen-


From   [email protected] (Vince Wiggins, StataCorp)
To   [email protected]
Subject   Re: st: Missing values in -egen-
Date   Tue, 14 Sep 2004 12:41:21 -0500

West Addison <[email protected]> notes that -egen- does not respect extended
missing values.  He writes,

> [...] In Stata version 8, I typed the following command:
>
> by id: egen statefcount = sum(state == .f)
>
> I got, for each id, a count of the number of observations with
> missing values of any sort (. plus .a through .z). [...]

-egen- is not behaving as it should.  What -egen- should do is evaluate
expressions involving missing according to the currently specified -version-
level.  In West's case, this is -version 8-, and -egen- should be
differentiating extended missing values (.a through .z).

While this could be fixed strictly in the -egen- ado code, a better solution
involves changes to the executable.  This will be fixed in the next executable
update.

Given his complete diagnosis of the problem, I am sure that West has already
found a workaround.  The easiest is probably to create an indicator variable
then sum on the indicator, transforming West's

      . by id: egen statefcount = sum(state == .f)

into

      . gen state_is_f = state == .f
      . by id: egen statefcount = sum(state_is_f)

 
-- Vince
   [email protected]

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



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index