Announcement

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

  • labelbook does not work with very long label names

    The labelbook command gives an error when it needs to process a label name that has 30 characters or more:

    Code:
    _v_<lblname> invalid name
    These label names are legal, but the problem seems to be that labelbook.ado likes to create a local macro of the form v_`lblname', and so the additional two characters result in an error (since local macros may only have 31 characters or less).

    For reference, I am on Stata/MP 17.0.

  • #2
    Why not just make shorter labels then

    Comment


    • #3
      Sure Jared, but if a label name is legal, then surely we would expect all built-in Stata commands to be able to work with it?

      Comment


      • #4
        Surely, we would. But, as I think this post illustrates, software can be funny sometimes.

        Comment


        • #5
          Indeed. Yet there's a difference between a software limitation and a bug.

          Comment


          • #6
            Agreed, but how is this a bug? A bug, to me, implies the program is doing something it shouldn't be doing. If local macros are being created and under the hood the software only allows for 31 characters by design for some reason, this is the software doing what it's intended to do. I mean presumably, we could change this somehow if we wanted to tinker around with what constitutes a macro in Stata, but I think that would be a bad idea on an individual scale, since if you passed the same do file to me, I'd need to also change how macros are defined.

            So I don't really think it's a bug, unless we could think of some way to make labelbook work better, which just involves changing an ado file.

            Comment


            • #7
              Perhaps I wasn't adequately clear. The label name as I said, is legal. Stata in general permits label names longer than 30 characters. Try for instance:
              Code:
              label define a1234567890123456789012356789012 1 "Yes" 2 "No"
              It works just fine. But then try
              Code:
              labelbook  a1234567890123456789012356789012
              which results in
              Code:
              _v_a1234567890123456789012356789012 invalid name
              This is a bug with labelbook.

              Comment


              • #8
                It might not be a bug from the developers' perspective, who must or should have foreseen this potential problem when they wrote the code (assuming the length of label names has not changed since). Perhaps they decided that the problem will occur only rarely and that the time required to write better code was not justified. That is fine but then this limitation should be documented. Also, we might want a better error message. Anyway, from a users' perspective, this is clearly a bug: given valid input, labelbook does not work as advertised.

                Comment

                Working...
                X