Skip to Main Content

How can I handle the “no room to add more observations” error? | Stata FAQ

You may go to use a data file in Stata and get the error…

no room to add more observations
r(901);

Stata is probably telling you that Stata has not allocated enough
memory to read the data file.  You can check to see how much memory is
allocated to hold your data using the memory command.  I am running
Stata under Windows, and this is what the memory command told me.

memory

Total memory                            1,024,000 bytes    100.00%

  overhead (pointers)                             0            0.00%
  data                                            0            0.00%
                                       ------------
  data + overhead                                 0            0.00%

  programs, saved results, etc.                 368            0.04%
                                       ------------
  Total                                         368            0.04%

  Free                                    1,023,632           99.96%

This tells me that I have a little bit under 1 megabyte free for reading in a
data file.  I have a data file called bigfile.dta that I want to
read that is about 1.7 megabytes, so that is why I was getting the no room to
add more observations
error. I will allocate 5 megabytes of memory with the
set
memory
command below, and then try using my file.

set memory 5m
(5120k)

use bigfile

Now that I have allocated enough memory, I am able to read the file. If you
want to allocate 5m (five megabytes) every time I start Stata, you can type

set memory 5m, permanently

And then Stata will allocate this amount of memory every time you start
Stata.

If you routinely use very large datasets then you might want to consider setting the
memory allocated to Stata to be a much larger value, say…

set memory 100m, permanently

You can permanently set the memory to any value that you require and that your computer can
manage. It is also possible to set the permanent memory size from the Stata preferences page for
your system.