Announcement

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

  • no observations r(2000);

    Good afternoon/evening.

    I am very new in Stata and I am trying to run a simple regression on some data that I have.

    Variable X has 75 observations while Variable Y has 74 observations.

    However, when I run the regression I get the following error:

    . regress Y X
    no observations
    r(2000);


    I already checked missing values:

    . count if !missing(Y, X)
    0

    I will appreciate your help. Thanks a lot,

  • #2
    Show us the results of
    Code:
     describe Y X
    Is either variable string?

    Comment


    • #3
      I cannot tell for sure, but I suspect that either or both variables are actually string variables. Please report what the output of the following gives.

      Code:
      desc X Y
      If they are strings, you will need to convert them to numeric type variables. You should go back to how you imported your data, but an on-the-fly approach is to do the following, assuming both X and Y are strings.

      Code:
      gen x = real(X)
      gen y = real(Y)
      drop X Y
      reg y x
      Please note that there is a convenient tool to use when asking for help on this forum. It is -dataex-. Simply type it into your Stata session, and it will give you a small snapshot of the data including any salient details that you can copy and paste into your post. We often ask for or require -dataex- output to best help people to solve their problems because much can be lost in a written description of a problem and the underlying code and data.
      Last edited by Leonardo Guizzetti; 19 Jul 2023, 14:41.

      Comment


      • #4
        Thanks for your answers.

        This is the output:

        . describe Y X

        Variable Storage Display Value
        name type format label Variable label
        --------------------------------------------------------------------------------------------------------------
        Y float %9.0g
        X float %9.0g


        I'll be looking forward your assistance.

        Thanks again,

        Comment


        • #5
          dataex please

          Note that

          Code:
          count if !missing(X, Y)
          0
          tells you that you have zero observations with non-missing values on X and Y, not that you have zero missing values.
          Last edited by Nick Cox; 19 Jul 2023, 14:51.

          Comment


          • #6
            dataex Y

            ----------------------- copy starting from the next line -----------------------
            Code:
            * Example generated by -dataex-. For more info, type help dataex
            clear
            input float Y
                    .
                    .
                    .
                    .
                    .
             51.66666
                    .
                   94
                    .
                    .
                    .
             84.16667
                    .
                    .
                    .
                    .
             63.33334
                    .
                    .
                    .
                   60
                    .
                    .
                    .
                    .
             58.33334
                    .
                    .
                 42.5
                    .
            75.454544
                    .
                53.75
                    .
                    .
             66.36363
                    .
                    .
             74.44444
                    .
                    .
                    .
                    .
                 72.5
                    .
                    .
             58.88889
                    .
             81.66667
                    .
                    .
                    .
                    .
                    .
                    .
             63.33334
                    .
             63.33334
                    .
            73.333336
                    .
                 87.5
                    .
                    .
                   50
                    .
             79.16666
                    .
                    .
             55.83334
                    .
                    .
                    .
             60.83334
                    .
                    .
                    .
                    .
                    .
             59.09091
                    .
                    .
                    .
                    .
                    .
                    .
                    .
                    .
                   80
                    .
                    .
                    .
            37.272728
                    .
                    .
                    .
                    .
                    .
                    .
                    .
            end
            ------------------ copy up to and including the previous line ------------------

            Listed 100 out of 341 observations
            Use the count() option to list more

            Comment


            • #7
              That's just Y but otherwise it looks as if nothing is possible. Why so many missing values?

              Comment


              • #8
                Nick is correct, these data are too sparse and nothing is possible. Perhaps the import process was mangled?

                Comment

                Working...
                X