Announcement

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

  • question on Use logical expressions and sum()

    This question is from N. J. Cox's article: https://journals.sagepub.com/doi/pdf...867X1101100210. See section 6.

    Code:
    sysuse uslifeexp, clear
    gen basevalue = sum((year == 1960) * le_female)
    I don't know why basevalue has 0 for all year before 1960 and 73.1 for all year after 1960.

    My understanding is that only year 1960 should give 73.1, and all other observations other than year 1960 should have missing value.

  • #2
    As mentioned in that Section sum() gives the cumulative or running sum and for 0, 0, ..., 0, 1, 0, ..., 0 that is 0 before 1 is encountered and 1 on that event and thereafter. We also multiply by 73.1. See also

    Code:
    help sum()
    Last edited by Nick Cox; 15 Mar 2020, 17:10.

    Comment

    Working...
    X