Announcement

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

  • 'no observations' error, but I don't have any missing data

    Hi all,

    I'm brand new to STATA so please forgive me if this is a stupid question. I've tried searching the forum and found that the 'no observations' error occurs in a regression when there are likely missing data in the variables.

    Well I removed my missing data (they were labeled .a etc) by recoding them all to periods so the variables look like this:

    Variable1
    1
    2
    3
    4
    .

    Variable 2
    1
    2
    .


    But I'm still getting the no observations error when I try to run a regression on the two variables!

    Can anyone please tell me how to fix this?

    Thank you!

  • #2
    Rachel:
    welcome to the list.
    Are you sure that your variables are not in string format?
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Carlo gives good advice. Strictly, what's important here is string variable or storage type. (String display formats are a step away from that.)

      You can tell what is a string variable by looking at the results of describe, or by finding that summarize refuses to give results. String variables that "should be" numeric can usually be tamed with destring.

      Comment


      • #4
        I am using GSS data, but the variables I was looking at are numeric!

        Comment


        • #5
          Okay I just checked and they are "byte" storage type. Isn't "byte" numeric?

          Comment


          • #6
            You haven't given us anything reproducible. Please look at FAQ Advice esp. #12 and help us with more detail.

            My final guess without being shown anything specific is that you are specifying an if condition which is not satisfied in the data.

            Comment


            • #7
              I just typed:
              reg variable1 variable2

              and got the error. I'm using STATA 13.0. I'm not sure what you mean with the if condition not being satisfied in the data. I haven't used any if commands that I am aware of!

              Comment


              • #8
                OK, you didn't use an if qualifier, so that guess is irrelevant. This is still too close to "My car|cat|partner|phone is not working as desired" to which the answer is "Something must be wrong then".

                Please try the following and copy and paste the results without change:

                Code:
                summarize variable1 variable2
                describe variable1 variable2
                regress variable1 variable2
                Did you read http://www.statalist.org/forums/help#stata as suggested and requested? Please, please do so. One of the things it says is

                Say exactly what you typed and exactly what Stata typed (or did) in response. N.B. exactly! If you can, reproduce the error with one of Stata's provided datasets, a small fragment of your dataset, or a simple concocted dataset that you include in your posting.
                So one of the implications of that is never to paraphrase (until you know enough Stata to be completely sure that the paraphrase omits nothing that might possibly be important).

                In particular, if your variable names are not literally variable1 variable2 you naturally will need to use their real names.

                Comment


                • #9
                  When using GSS data in particular, it is very, very common to have observations on one variable for certain years, and a different variable for other years. Plenty of cases with V1, plenty with V2, but none with V1 *and* V2.

                  Comment


                  • #10
                    In fact, Rachel signalled a problem in #1 that we all overlooked, or so it seems, because we were taking the thread title on trust.

                    I removed my missing data (they were labeled .a etc) by recoding them all to periods.
                    Periods (system missing .) are very much missing values. It doesn't make any difference whether a value is system missing or one of .a to .z: the corresponding observation won't be included in a regression.

                    Comment


                    • #11
                      Originally posted by Nick Cox View Post
                      In fact, Rachel signalled a problem in #1 that we all overlooked, or so it seems, because we were taking the thread title on trust.



                      Periods (system missing .) are very much missing values. It doesn't make any difference whether a value is system missing or one of .a to .z: the corresponding observation won't be included in a regression.

                      I was told that the periods are fine for running regressions as STATA ignores them! Sigh.

                      So I tried to drop all the missing data (the periods) and I ended up deleting all of my observations.

                      So my new question is simply how do I delete some observations without deleting all of them.

                      This was the code I used for trying to delete the missing data:

                      drop if variable1==.

                      Comment


                      • #12
                        Stata [NB] certainly ignores them in a regression -- that was correct advice -- but that evidently means, in this case, nothing to work with. It's exactly like you being asked to draw a scatter plot and some of the values are missing. You can't add them to your scatter plot. Stata can't use them in a regression (how would it do that?).

                        It sounds as if you want to drop a variable, not observations. Look at

                        Code:
                        help drop
                        to see that there are two syntaxes.

                        If variable1 (if you are really using dopey names like this, change them) is all missing, then

                        Code:
                        drop variable1
                        is a sensible thing to do, but it won't make any regression possible that was impossible before.

                        Comment


                        • #13
                          Originally posted by ben earnhart View Post
                          When using GSS data in particular, it is very, very common to have observations on one variable for certain years, and a different variable for other years. Plenty of cases with V1, plenty with V2, but none with V1 *and* V2.

                          This was the answer! I didn't realize different ballots occurred within the same year!

                          Thank you all for your help!

                          Comment


                          • #14
                            Hello! I am having the very same problem. I do not have missing variables, all the data are numeric but I get a "no observation" error. How to solve that GSS problem? Other options did not work for me.

                            Here is my dataset

                            Baseflow

                            .9572
                            .99
                            .9805
                            .9783
                            .9927
                            .9491
                            .9704
                            .9523
                            .966
                            .9563
                            .9348
                            .9287
                            .8487
                            .8957
                            .9121
                            .8138
                            .8042
                            .7891
                            .945
                            .9446
                            .8944
                            .888
                            .9412
                            .9679
                            .9033
                            .9798
                            .9784
                            .9754
                            .9679
                            .9872
                            .9845
                            .9843
                            .9751
                            .9944
                            .9668
                            .9742
                            .9772
                            .9968
                            .9795
                            .98

                            Comment


                            • #15
                              .

                              Comment

                              Working...
                              X