Announcement

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

  • Logit Error r(2000) - No Observations

    Hi everyone,

    I am new to Stata and have been struggling with running logit. I am using StataSE 13. When I run logit, I keep getting "no observations; r(2000)". Here is basic info about my data set:

    Number of observations: 88
    Dependent variable: "forsames"
    Independent variable: "polaff" (politicalaffiliation)

    Code:
    *Tabulating the dependent variable
    tabulate forsames
    
    encode politicalaffiliation, generate (polaff)
    
    tabulate polaff
    tabulate polaff, nolabel
    
    *Generating political affiliation dummy variables
    generate amindep=0
    replace amindep=1 if polaff==1
    
    generate democrat=0
    replace democrat=1 if polaff==2
    
    generate green=0
    replace green=1 if polaff==3
    
    generate indep=0
    replace indep=1 if polaff==4
    
    generate libert=0
    replace libert=1 if polaff==5
    
    generate peace=0
    replace peace=1 if polaff==6
    
    generate repub=0
    replace repub=1 if polaff==7
    
    *Political affiliation as explanatory variable, democrats as baseline
    logit forsames amindep green indep libert peace repub
    I have checked the manual and other help threads (e.g. I am using 0,1 variables; I'm not missing any data, etc.), but nothing seems to be working.

    I would be incredibly grateful for any help or suggestions!
    Last edited by Ellen Tsai; 24 Jul 2015, 23:53.

  • #2
    Ellen:
    welcome to the list.
    You may want to post your .dta file so that other listers may want to repeat your analysis.
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Thank you for the suggestion, Carlo. I have added the .dta file to my original post.

      Comment


      • #4
        Ellen:
        unfortunately, your attachment was probably lost along the wire.
        Kind regards,
        Carlo
        (Stata 19.0)

        Comment


        • #5
          I'm afraid I don't understand what you mean. The .dta file is working for me when I open it.

          Comment


          • #6
            forsames is a string variable. Look at:
            Code:
            describe forsames
            You need a numeric variable:
            Code:
            destring forsames , generate(forsames_n)

            Comment


            • #7
              Oh, I see! Thank you very much for your help. Problem solved

              Comment


              • #8
                Ellen:
                now that I can open the .dta I second in full Svend's helpful advice.
                Kind regards,
                Carlo
                (Stata 19.0)

                Comment

                Working...
                X