Announcement

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

  • Too many variables specified error with keep and browse command

    I have created a large local (called stubs) of variable stubs with wild cards e.g. "var1_* var2_* var3_*". The list is quite long (~1,000 variables) when expanded out. When I execute either keep stubs or browse stubs, I'm getting an error message "too many variables specified", which I've never seen before. As the dataset is currently loaded into Stata, I'm not sure why keeping or browsing a smaller subset would cause an issue. Any ideas?

  • #2
    Maybe it is related to the - maxvar - specification plus the Stata flavor.

    According to the Stata Manual,

    The maximum number of variables in your dataset is limited to
    maxvar. The default value of maxvar is 5,000 for Stata/MP and
    Stata/SE, and 2,048 for Stata/IC. With Stata/MP and Stata/SE, this
    default value may be increased by using set maxvar. The default
    value is fixed for Stata/IC.
    Best regards,

    Marcos

    Comment


    • #3
      I don't think the problem is a result of maxvar, because as you say, the dataset is loaded in memory, so any exhaustive list of variables shouldn't contain more variables than there are in the dataset.

      What happens if you try
      Code:
      keep *
      And, are you sure you haven't accidentally duplicated some of the stubs? Your sample list of stubs appears to be invented; perhaps your actual list is more complicated and you've accidentally duplicated things. The following example demonstrates that the expanded list does not have duplicates removed before the variables are counted.
      Code:
      . set maxvar 2048
      
      . forvalues i=1/2048 {
        2. generate v`i'=.
        3. }
      
      . keep *
      
      . keep * *
      too many variables specified
      r(103);
      
      .

      Comment

      Working...
      X