Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Splitting groups based on cut-off value

    Hi all,

    I would like to split a group based on it's median value of 38.8.

    - Values less than 38.8 = 0
    - Values >= 38.8 = 1

    When I used sum var, detailed, I looked at the 50% and determined that as median. The same group has also a lot of missing values (100 or so). When using the code "sum", does it include the missing values in its determination of the median?



    Also, when I split the group into binary values by code:

    - gen var_39 = 1 if RA_reservoir >= 38.85
    - replace var_39 = 0 if RA_reservoir < 38.85

    I think it includes missing values and assigns a value of 0. How do I tell it to ignore the missing values?

    Thank you already!

    Rajiv

  • #2
    1. no, missing values are not included in the determination of the median

    2. in Stata, a missing value is considered to be a "larger" number than any non-missing values so you need to do one of the following:
    Code:
    you can just change what you have by saying, e.g.,
    replace var_39=. if RA_reservoir==.
    
    or, either re-do now or remember for the future:
    replace var_39 = 0 if RA_reservoir < 38.85 & RA_reservoir<.
    
    or you can do all in one statement, such as
    gen byte var_39= RA_reservoir>=38.85 & !missing(RA_reservoir)

    Comment


    • #3
      Oh great, that is a great solution! For now, I just dropped all observations with those missing values. But I will remember this for the future.

      Thank you Rich!

      Comment

      Working...
      X