Announcement

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

  • Automatically wrapping long labels

    Colleagues,

    I'm trying to follow the advice on the Statalist concerning the automatic wrapping of long labels. I'm trying to modify the code from the post to suit my needs but I'm getting the invalid syntax error. It is not entirely obvious to me where is the error.

    Code:
    // Fix the long labels
    local relabels ""
    levelsof ifcrglady, local(groups)
    foreach g in `groups' {
        local label : label ifcrglady `g'
        local len : length label
        if `len' > 20 {
            local p1 : piece 1 20 "`label'", nobreak
            local p2 : piece 2 20 "`label'", nobreak
            local relabels "`relabels' `g' `""`p1'" "`p2'"'" '"
            }
        }
    Kind regards,
    Konrad
    Version: Stata/IC 13.1

  • #2
    Code:
     local len : length label
    should be
    Code:
     local len : length local label
    There may be other errors, but fix that one first.

    Comment


    • #3
      Thank you very much. As a matter of fact, I solved the problem by using Nick Winter's splitvallabels (SSC). Very handy programme, I only had to recode the grouping variable and modify the labels. Initially my grouping was in a format:

      0 - group A
      ...
      3 - group D

      I had to change it to:

      1 - Group A
      ...
      4 - Group D

      For some reason splitvallabels, was not picking the group for 0 values.
      Kind regards,
      Konrad
      Version: Stata/IC 13.1

      Comment

      Working...
      X