Announcement

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

  • egen stata sum by group is missing some obervations

    Why is my code missing out some observations (or separate) when they should be calculated together. For example, I want to sum disease cases in the field (Case1) sorted according to Municipio but instead of having 3s in all 4 results, I have 1 and 2s meaning the first one is treated separate. Any suggestions?

    The code I used is as as follows and it gave the same answer as highlighted in the last three columns:
    egen sum_var = sum( Case1 ), by( Municipio ) for sum_var and bysort Municipio: egen cases= total ( Case1 ) for Cases.

    Attached Files

  • #2
    Your screenshot is unreadable (by me at least). Please do read and act on https://www.statalist.org/forums/help#stata

    Comment


    • #3
      I appreciate your response. I could not express the question quiet clearly, but thanks for pointing to me the resources to help me improve. I have resolved the issue, It was coz the spreadsheet had spaces making the string to be read as different. I had to use Trim in Excel which resolved the issue and now Stata is behaving normally.

      Comment

      Working...
      X