Announcement

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

  • Error code: r(451) repeated time values in sample

    1. I am trying to create a graph of trends of a given event over time. So I tried to set my time variable (which is year) using "tsset year, yearly" but it's giving me the error code r(451) repeated time values in sample. I am sorry in advance if this was a nasty explanation but I am new with STATA and I basically don't know what I'm doing half the time. Please let me know what I should be doing instead.

  • #2
    Do you have panel data?

    Have you tried

    Code:
    duplicates report year
    ?

    Comment


    • #3
      No, it's not, the data has over 90,000 observations and each observation is a different subject I believe. It's a survey data collected over the course of 17 years.

      Comment


      • #4
        Your command

        Code:
        tsset year
        is only going to work if each observation is for a single year, not repeated. Perhaps you need to calculate some summary for each years in the data. More detail is needed on your dataset to advise.

        Comment


        • #5
          What details would you need for you to advise please.

          Comment


          • #6
            Would I need to generate a new time variable? The data is from 1999-2016.

            Comment


            • #7
              I already suggested

              Code:
              duplicates report year
              See also https://www.statalist.org/forums/help#stata for detailed advice. Every new message prompt advises reading this document.

              Comment


              • #8
                Here's what I got with the syntax "duplicates report year"
                copy up to and including the previous line ------------------
                Listed 100 out of 97770 observations
                Use the count() option to list more
                . duplicates report year
                Duplicates in terms of year
                Copies Observations Surplus
                7821 7821 7820
                8086 8086 8085
                8291 8291 8290
                8591 8591 8590
                9965 9965 9964
                9971 9971 9970
                10045 10045 10044
                10122 10122 10121
                11039 11039 11038
                13839 13839 13838

                Comment


                • #9
                  It seems that you have about 10 years of data. You may find that egen will count cases for you but we still need a data example -/ which I think you tried, but no results are visible

                  Comment


                  • #10
                    Thank you for your time

                    here's the data example

                    copy starting from the next line ------------------- ---
                    Code:
                    * Example generated by -dataex-. For more info, type help dataex
                    clear
                    input float(inject year) double(sdmvpsu sdmvstra poverty_ratio) float(weight    white    age10    latinx    black    lowincome    poverty    married    no_highschool    college_grad    pot    drink90centile    gender    cancer    smoker)
                    . 1999 1  5  .86 1080.7865 0  .2 0 1 1 1 . . . . . 0 . .
                    . 1999 3  1    5  2964.293 1 7.7 0 0 0 0 . 0 1 . 0 1 1 0
                    . 1999 2  7 1.47 4846.8535 1   1 0 0 0 0 . . . . . 0 . .
                    . 1999 1  2  .57 1149.5688 0  .1 0 1 1 1 . . . . . 1 . .
                    . 1999 2  8    5  10116.76 1 4.9 0 0 0 0 1 0 1 . 1 1 0 1
                    . 1999 2  2 1.21  4056.472 0 1.9 0 0 1 1 0 . . . . 0 . .
                    . 1999 2  4    . 2483.5654 0 5.9 0 1 . . 1 1 0 . 0 0 0 1
                    . 1999 1  6  .53  3511.121 1 1.3 0 0 1 1 . . . . . 1 . .
                    . 1999 2  9    .  836.6039 0 1.1 0 1 . . . . . . . 0 . .
                    . 1999 1  7    . 2341.2405 0 4.3 0 1 . . 0 0 0 . 0 1 0 1
                    . 1999 2  1 1.25  4080.418 1 1.5 0 0 0 1 0 . . . . 1 . .
                    0 1999 2  6 4.93 10289.243 1 3.7 0 0 0 0 0 0 0 . 0 1 0 0
                    . 1999 2 13 1.07 183.04956 0   7 1 0 1 1 1 1 0 . 0 1 0 1
                    . 1999 1 12 2.67 1681.3016 1 8.1 0 0 0 0 0 1 0 . 0 1 0 1
                    . 1999 2 11 4.52  12056.82 1 3.8 0 0 0 0 0 0 1 . 1 0 0 1
                    . 1999 1 11  .38 1315.0804 0 8.5 0 1 1 1 0 1 0 . 0 0 0 0
                    . 1999 1  5  .92  884.5288 0  .2 0 1 1 1 . . . . . 1 . .
                    . 1999 1  8 2.84  3330.176 1  .1 0 0 0 0 . . . . . 0 . .
                    . 1999 2 13  2.4 215.42116 0   0 1 0 0 0 . . . . . 1 . .
                    0 1999 2  2 3.03 1769.0753 0 2.3 1 0 0 0 1 1 0 . 1 0 0 1
                    . 1999 2  3  1.8  313.6836 0 1.8 1 0 0 0 0 . . . . 1 . .
                    . 1999 2  2  .75  778.1287 0 1.3 0 1 1 1 . . . . . 0 . .
                    . 1999 2  4    5   648.072 0 1.2 0 1 0 0 . . . . . 0 . .
                    . 1999 2 12 2.67  7519.466 1 5.3 0 0 0 0 1 0 0 . 1 0 1 1
                    0 1999 1  5 1.77  13476.03 1 4.2 0 0 0 0 1 0 0 . 1 0 0 1
                    . 1999 2 13 2.51 203.05527 0 1.4 1 0 0 0 0 . . . . 0 . .
                    . 1999 2 13    . 212.86397 0 1.8 1 0 1 . 0 . . . . 1 . .
                    . 1999 2  1 3.43  4337.942 1 1.8 0 0 0 0 0 . . . . 1 . .
                    . 1999 2 12 1.07  4723.968 1 6.2 0 0 1 1 0 0 0 . 0 1 0 1
                    . 1999 2  5    . 1272.3865 0  .7 0 1 . . . . . . . 0 . .
                    . 1999 2  2  .33  262.2222 0 1.5 1 0 1 1 0 . . . . 0 . .
                    . 1999 1  5 1.54 1637.6687 0   1 0 1 0 0 . . . . . 1 . .
                    . 1999 1 13 1.78  830.8915 0 4.6 1 0 0 0 . 0 0 . 1 1 0 1
                    0 1999 1  7  .92  2965.016 0 3.8 0 1 0 1 0 0 0 . 0 0 0 1
                    . 1999 2 12    5  3611.649 1  .2 0 0 0 0 . . . . . 1 . .
                    . 1999 2 10 4.61 1461.2855 0  .6 0 1 0 0 . . . . . 0 . .
                    . 1999 2 12    5  3611.649 1  .1 0 0 0 0 . . . . . 1 . .
                    . 1999 1  6    . 519.71936 0  .1 1 0 . . . . . . . 1 . .
                    . 1999 1 13  .32 1168.8622 0  .7 0 1 1 1 . . . . . 1 . .
                    . 1999 1 13    .  239.6415 0 6.8 1 0 . . 0 1 0 . 0 0 0 0
                    . 1999 1 11 1.31  2775.342 1  .2 0 0 1 0 . . . . . 1 . .
                    . 1999 1  2    .  994.2823 0 1.8 0 1 . . 0 . . . . 0 . .
                    . 1999 2  9 2.93  3780.509 0  .6 1 0 0 0 . . . . . 0 . .
                    . 1999 2 12    5  3625.463 1 1.5 0 0 0 0 0 . . . . 0 . .
                    0 1999 1  4  .75 2040.2247 0 3.3 1 0 1 1 0 0 0 . 0 0 0 0
                    . 1999 2  5  1.2 1172.6309 0 8.5 0 1 1 1 0 1 0 . 0 0 0 1
                    . 1999 1  8 2.13  3553.184 1 1.6 0 0 0 0 0 . . . . 0 . .
                    . 1999 1  1 2.04  1940.872 1   0 0 0 0 0 . . . . . 0 . .
                    . 1999 1  3 1.19  329.3678 0 1.2 1 0 0 1 . . . . . 1 . .
                    . 1999 1 10  .19  943.2267 0  .1 0 1 1 1 . . . . . 0 . .
                    . 1999 1  9  1.8 1917.8916 1   0 0 0 0 0 . . . . . 0 . .
                    . 1999 1  2 2.18 1024.0891 0 1.9 0 1 1 0 . . . . . 0 . .
                    . 1999 1  4  .18     299.3 0 1.8 1 0 1 1 0 . . . . 0 . .
                    . 1999 2  8 2.29  804.4081 0  .2 0 1 0 0 . . . . . 1 . .
                    . 1999 2  9 3.33  902.5928 0 6.1 1 0 0 0 0 0 1 . 0 0 0 1
                    . 1999 1 12    .   9736.99 1 2.1 0 0 . . 1 1 0 . 1 1 0 1
                    . 1999 2  5    5 10115.015 1 3.9 0 0 0 0 1 0 1 . 0 1 0 0
                    . 1999 1 13    . 220.23317 0 1.8 1 0 . . 1 . . . . 0 . .
                    . 1999 1  6  .97 220.43527 0   7 1 0 1 1 1 1 0 . 1 1 1 1
                    . 1999 2  4    . 4604.3066 1  .5 0 0 . . . . . . . 1 . .
                    . 1999 1  8 1.77 1190.0878 0  .4 0 1 0 0 . . . . . 1 . .
                    . 1999 1  2  1.8  5135.599 0 1.7 0 0 0 0 0 . . . . 0 . .
                    . 1999 2 13    . 165.08583 0   0 1 0 1 . . . . . . 0 . .
                    . 1999 1  9    5 1489.9073 0 6.3 0 1 0 0 1 0 0 . 0 0 0 1
                    . 1999 2 10    .  7319.826 0  .9 0 0 . . . . . . . 1 . .
                    . 1999 1  3 4.13  2846.422 0 3.7 1 0 0 0 0 0 0 . 0 1 0 0
                    . 1999 1  3    .  308.0782 0 1.3 1 0 1 . . . . . . 1 . .
                    . 1999 1 12 4.34 286.72882 0 1.9 1 0 0 0 0 . . . . 0 . .
                    . 1999 1  7 2.57  3441.092 0 2.7 0 1 0 0 0 0 1 . 0 1 0 0
                    . 1999 2  3    .  730.3906 0  .3 1 0 . . . . . . . 0 . .
                    . 1999 2 13 1.26 228.42336 0 6.9 1 0 0 1 1 0 0 . . 1 0 1
                    . 1999 2  9 2.14  475.5532 0 1.5 0 1 0 0 0 . . . . 0 . .
                    . 1999 1  9  .16 1363.7533 0  .7 0 1 1 1 . . . . . 0 . .
                    . 1999 1  6  1.7  370.8928 0 1.3 1 0 0 0 . . . . . 0 . .
                    . 1999 2  7    .  534.4499 0  .8 1 0 1 . . . . . . 1 . .
                    . 1999 1 13 1.13  209.7459 0 1.3 1 0 1 1 . . . . . 0 . .
                    0 1999 2  8 2.99  7965.569 1 2.5 0 0 0 0 1 0 0 . 1 1 0 1
                    . 1999 3  1    .  4998.154 1   1 0 0 . . . . . . . 1 . .
                    . 1999 1  5  .79 3666.9485 1  .2 0 0 0 1 . . . . . 0 . .
                    . 1999 1 11    . 1315.0804 0 7.5 0 1 . . 0 1 0 . 0 0 1 1
                    . 1999 2 12 3.59  9690.091 1   3 0 0 0 0 1 0 1 . 0 1 0 0
                    . 1999 1  8    5  5015.081 0  .3 0 0 0 0 . . . . . 0 . .
                    . 1999 1  7  2.4 1172.6309 0   6 0 1 0 0 0 1 0 . 0 0 0 1
                    . 1999 2  1 3.53  4180.659 1 1.4 0 0 0 0 0 . . . . 1 . .
                    . 1999 1 12    . 271.58502 0 1.8 1 0 . . 1 . . . . 1 . .
                    . 1999 2  1 2.16  5189.054 1 6.3 0 0 1 0 0 0 0 . 0 0 1 1
                    . 1999 2 10    5 597.96387 0 1.4 1 0 0 0 0 . . . . 0 . .
                    . 1999 1 12  .74  266.9353 0 1.9 1 0 1 1 0 . . . . 0 . .
                    . 1999 1  9 1.15  1382.375 0  .3 0 1 1 1 . . . . . 1 . .
                    . 1999 2  5 2.22  4931.121 1 6.1 0 0 0 0 1 0 0 . . 1 0 1
                    . 1999 2  6  .63  3598.716 1 1.7 0 0 1 1 0 . . . . 1 . .
                    . 1999 2 10 4.35 4408.8896 0 3.1 0 1 0 0 1 0 1 . . 1 0 0
                    . 1999 1 12    5  5897.769 0 6.3 0 0 0 0 1 0 0 . 0 0 0 0
                    . 1999 2  4 4.44 1128.1979 0 6.1 0 1 0 0 1 0 0 . 0 0 1 0
                    . 1999 2 13    .  824.2693 0 4.5 1 0 1 . 0 1 0 . . 0 0 1
                    1 1999 1  8 2.51  2804.043 0 4.3 0 1 0 0 . 1 0 . 0 0 0 0
                    0 1999 2  5    .  4028.339 0 3.2 0 1 . . 0 0 0 . 0 1 0 1
                    . 1999 2  4  .84 1128.1979 0 6.2 0 1 1 1 0 1 0 . . 0 0 1
                    . 1999 2  2    . 251.19855 0   0 1 0 1 . . . . . . 0 . .
                    . 1999 1  5  .12  937.8449 0 1.4 0 0 1 1 0 . . . . 0 . .
                    end
                    copy up to and including the previous line -------------- ---

                    Comment


                    • #11
                      It's not clear to me what your observations (records, rows) represent, and no one else is jumping into the conversation. I don't think it's individual people -- which person has a poverty ratio? It might be survey data in the sense of [SVY].

                      Thanks for the data example, but I don't think I can help further.

                      Comment


                      • #12
                        Rookie Stad:
                        Since you have -sdmvpsu- and -sdmvstra-, it seems that your data actually come from a surevy (see -svy- related entries in Stata .pdf manual).
                        Please consider that dealig with these data implies advanced technical capabilities (that I do not own, just to be crystal-clear).
                        Please see https://www.statalist.org/forums/help#realnames, as it might apply, Thanks.
                        Kind regards,
                        Carlo
                        (StataNow 18.5)

                        Comment


                        • #13
                          Thank you Nick and Carlo. I appreciate your time

                          Comment

                          Working...
                          X