Announcement

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

  • how to calculate cumulative observation for a certain time interval, like 10 years?

    Hi Guys:
    i am new here.
    I have a dataset that records two states and if they had militarized disputes in a certain year. so what i want to do is to calculate up till a single year, how many militarized disputes they have had in the previous ten years (including this year).
    I find this thread: https://www.statalist.org/forums/for...year-intervals. However, the rangestat command gives somewhat weird result. here is my command: rangestat (sum) y, interval(year 0 10) by(id). and attach my weird result. if anyone could tell me what's going wrong or how to fix it, i would appreciate it greatly!
    Click image for larger version

Name:	screen shot.png
Views:	2
Size:	315.6 KB
ID:	1520263
    Attached Files

  • #2
    OK, after reading the -help- document for "rangestat", i think i find the answer. the correct command should be this: rangestat (sum) y, interval(year -10 0) by (id). it is because i want previous 10 years cumulative observations.

    Comment


    • #3
      Thank you for closing the thread by showing the solution you found. Others who encounter similar problems in the future and search the Forum for help will benefit from your efforts.

      Comment


      • #4
        Note that

        Code:
        interval(year -10 0)
        gives you a sum over 11 years, not 10. Just count down from -10 to -1 and don't stop -- include 0 too.

        The syntax for the previous ten years is

        Code:
        interval(year -10 -1)
        and it's a misuse of the word previous to include the present year. Conversely,

        Code:
        interval(year -9 0)
        sums over ten years that are the previous nine and the present year.

        In an international community it's hard to be sure. But if "Axe Jack" is some kind of pseudonym please register with a full real name instead. Also, rangestat is community-contributed from SSC, as you are asked to explain.

        Comment


        • #5
          Originally posted by Clyde Schechter View Post
          Thank you for closing the thread by showing the solution you found. Others who encounter similar problems in the future and search the Forum for help will benefit from your efforts.
          Thanks for your kind words!

          Comment


          • #6
            Originally posted by Nick Cox View Post
            Note that

            Code:
            interval(year -10 0)
            gives you a sum over 11 years, not 10. Just count down from -10 to -1 and don't stop -- include 0 too.

            The syntax for the previous ten years is

            Code:
            interval(year -10 -1)
            and it's a misuse of the word previous to include the present year. Conversely,

            Code:
            interval(year -9 0)
            sums over ten years that are the previous nine and the present year.

            In an international community it's hard to be sure. But if "Axe Jack" is some kind of pseudonym please register with a full real name instead. Also, rangestat is community-contributed from SSC, as you are asked to explain.
            Hi Nick, thank you very much for the comments. I get it. need to be more careful about what exactly i want. I will figure out how to replace the pseudonym with my real name.

            Comment


            • #7
              It's not difficult See #6 in the FAQ Advice https://www.statalist.org/forums/help all posters are asked to read first. And please swing by #12 there to read how screenshots are not usually as helpful as you hope.

              Comment

              Working...
              X