Announcement

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

  • "observation number out of range" problem

    Hello everyone,
    I am working on an Econometrics problem with a dataset. My command lines are as follows:

    // Set number of observations
    eststo clear
    set obs 1000
    // Generate variables
    /// y = beta0 + beta1 * x + u.
    g id = _n
    g x = runiform()
    g u = rnormal()
    g y = 3*x + u
    // Estimate the model using OLS
    reg y x
    eststo m1 //store the results

    // Replicate each observation by 4
    expand 4, gen(dupind)

    // Estimate the model using OLS and the new sample
    reg y x
    eststo m2
    // Cluster the standard error
    reg y x, cluster(id)
    eststo m3

    // Show all results
    esttab m*, se(3)

    log close


    but it always reminds me that
    "observation number out of range
    Observation number must be between 3,010 and 281,474,976,710,654. (Observation numbers are
    typed without commas.)"

    when it comes to "set obs 1000"

    But my dataset contains exactly 3010 data points, and I really don't know where went wrong.

    Thanks a lot to any help!


  • #2
    You have data in memory which has 3010 observations (rows), than you tell Stata to set the number of observations to 1000. That is obviously impossible without drastically changing the data, so Stata won't allow that. If you want to drop observations, you have to do so explicitly with either the drop or keep commands.
    ---------------------------------
    Maarten L. Buis
    University of Konstanz
    Department of history and sociology
    box 40
    78457 Konstanz
    Germany
    http://www.maartenbuis.nl
    ---------------------------------

    Comment


    • #3
      My teacher provided this reference file and seems I didn't really understand the course...... Thank you very much! I will try it out.

      Comment


      • #4
        Be careful, you need a really good reason for dropping observations. "Somebody gave me a file where they want a 1000 observations" is not a good reason.
        ---------------------------------
        Maarten L. Buis
        University of Konstanz
        Department of history and sociology
        box 40
        78457 Konstanz
        Germany
        http://www.maartenbuis.nl
        ---------------------------------

        Comment


        • #5
          The code seems to imply that students are expected to create their own fake dataset. if so, then

          Code:
          clear 
          to drop all data in memory is not just fine but expected. But you should clarify the problem with your teachers, not with us.

          Comment


          • #6
            okay,thank you all very much!

            Comment

            Working...
            X