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

Re: st: Missing values in -egen-

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

West Addison <> 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

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)


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

-- Vince

*   For searches and help try:

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