Home  /  Resources & support  /  FAQs  /  -no room- error message
Note: This FAQ applies to older versions of Stata; in particular, Stata 4.0 and earlier. It does not apply to the current version.

Why do I get the no room to add ... error message?

Title   no room error message
Author Stata technical support

In Stata 4.0 and previous versions, the user is responsible for specifying how much memory is allocated to variables and how much to observations. Stata offers 3 commands to allow the user to control these memory settings.

If you see the error message no room to add more ... while trying to run a command, then you will need to save your dataset to a file (if you have not already done so) and clear the memory before you can change the settings.

When dealing with these memory settings, width is the total number of bytes to hold a single observation. A byte variable takes up 1 byte, an integer variable takes up 2 bytes, a float or a long takes up 4 bytes, a double takes up 8 bytes, and a str# variable takes up # bytes. So, the total width can be found by multiplying these values by the number of variables of each type and summing.

When specifying your memory settings, keep in mind that

  1. When you run commands on the dataset, they will need to generate temporary variables (which requires a bigger maxvar and/or width).

  2. Matrices are stored between the number of observations that you have in the dataset and the maximum number of observations (which requires a bigger maxobs).
So, be sure to set width and maxvar to be large enough to accommodate the extra variables that will need to be created. The no room to add more variables may be issued if either the width or maxvar are too small.

Method 1: Using the memsize command

Before loading in your dataset, you can ask Stata for advice.

        . memsize using nlswom
        
               variables:                    23
               width:                        34
               observations:                 69515
               data set size:                2308 k
        
               data will not fit in current partition
               insufficient total memory
If Stata gives the message insufficient total memory, then you will have to exit Stata, increase the /k option, and restart.
        . memsize using nlswom
        
               variables:                    23
               width:                        34
               observations:                 69515
               data set size:                2308 k
        
               data will not fit in current partition
        
                                              approx.   free float    free
               command                        maxobs    variables      obs
               -----------------------------------------------------------
         (F4)  set maxvar 33 width 44          91081          2      21566
         (F5)  set maxvar 46 width 57          70308          5        793
         (F6)  set maxvar 43 width 54          74214          5       4699
In this case, the data will not fit with the settings that I currently have in place. Stata has offered 3 different settings that I may use that will allow me to load in the data. I can choose one of those settings by either typing in the command or pressing the appropriate function key.

Method 2: Using the set commands

In order to determine the total amount of RAM required for a dataset so that you can set the /k option, you can

        . describe using nlswom
        
        Contains data                                 NLS Women 14-24 in 1968
          Obs: 69515
         Vars:    23
        Width:    34
          1. idcode       int    %8.0g                NLS id
          2. year         byte   %8.0g                interview year
          3. birth_yr     byte   %8.0g                birth year
          4. age          byte   %8.0g                age in current year
          5. race         byte   %8.0g                1=wh, 2=bl, 3=other
          6. msp          byte   %8.0g                1 if married, spouse present
          7. nev_mar      byte   %8.0g                1 if never yet married
          8. in_sch       byte   %8.0g                1 if enrolled in school
          9. grade        byte   %8.0g                current grade completed
         10. collgrad     byte   %8.0g                1 if college graduate
         11. not_smsa     byte   %8.0g                1 if not SMSA
         12. c_city       byte   %8.0g                1 if central city
         13. south        byte   %8.0g                1 if south
         14. ind_code     byte   %8.0g                industry of employment
         15. occ_code     byte   %8.0g                occupation
         16. union        byte   %8.0g                1 if union
         17. wks_ue       byte   %8.0g                weeks unemployed last year
         18. ttl_exp      float  %9.0g                total work experience
         19. job_num      byte   %8.0g                job number
         20. tenure       float  %9.0g                job tenure, in years
         21. hours        int    %8.0g                usual hours worked
         22. wks_work     byte   %8.0g                weeks worked last year
         23. ln_wage      float  %9.0g                ln(wage/GNP deflator)
        Sorted by:
Now, deciding on what to specify for the /k option requires us to know what we will specify for width and maxobs. Let's say we want to leave room to add 4 variables of type double. This increases the width by 32 to a total of 66. Let's leave room for 800 additional observations for a total of 70315. We can use Stata to perform our calculation:
        .di 70315*66/1024
        4532.0215
This tells us that we should specify /k4533 or higher and after starting Stata issue
        . set maxvar 40 width 66