Announcement

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

  • Error Message _lsubstitution_code_casualty_code invalid name

    So I have been trying to copy labels from my existing dataset before a ~collapse command. This is the code that I use
    Code:
    foreach v of var * {
        local l`v' : variable label `v'
            }
    However after I run this command, I get an error
    Code:
    _lsubstitution_code_casualty_code invalid name
    r(198);
    Any help would be appreciated

  • #2
    It is too long to qualify as a variable name, which I guess is what you're trying downsteam.

    Code:
    . di length("_lsubstitution_code_casualty_code")
    33
    See

    Code:
    help limits
    for a handy list of limits in your Stata, In mine the limit on characters in variable names is 32.

    History note: Back in the day it was 8, IIRC.

    Comment


    • #3
      Thanks Nick. Rather than variable name, it was too long to qualify as a local macro name. As a side question, is there a way to change these limits, or is it given. Like my limit on variable names is 32 and local macro names is 31, so can i increase it in any way?

      Comment


      • #4
        Sorry, no. In this context, limits are binding and not default settings. You can ask StataCorp to change them in some future release. Other options are more far-fetched, such as clone Stata but change the limits.

        Comment


        • #5
          Thanks a lot Nick

          Comment

          Working...
          X