Announcement

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

  • Overcoming the 65,000 Limit of Labelling Values

    I am currently trying to apply a value label Mien(label define Mien 1/1000 "Suppressed" 1001/10000000 "Unsuppressed" 0 "Undetectable" -1 "Failed" -2 "Invalid") to a numeric list ranging from -2 to 10000000 (count of about 46000). Unfortunately it is not working. I would appreciate some help. I noticed that there is a numeric limit of about 65,000.

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float Result
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -2
    -1
    -1
    -1
    -1
    -1
    end
    label values Result Result
    label def Result -2 "Invalid", modify
    label def Result -1 "Failed", modify

  • #2
    That limit of about 65,000 distinct values for a value label is absolute. The best you can do is to create an additional variable Mien_cat that reflects the category:

    Code:
    gen Mien_cat = "Failed" if Mien == -1
    replace Mien_cat = "Invalid" if Mien == -2
    replace Mien_cat = "Undetectable" if Mien == 0
    replace Mien_cat = "Suppressed" if inrange(Mien, 1, 1000)
    replace Mien_cat = "Unsuppressed" if inrange(Mien, 1001, 10000000)

    Comment


    • #3
      For problems like that, one typically creates a new variable, rather than giving lots of values the same label.

      Code:
      gen indicator = 1 if inrange(Result, 1, 1000)
      replace indicator = 0 if Result > 1000 & Result < .
      replace indicator = .a if Result == 0
      replace indicator = .b if Result == -1
      replace indicator = .c if Result == -2
      
      label define mien 1 "Suppressed" 2 "Unsuppressed" .a "Undetectable" .b "Failed" .c "Invalid"
      label value indicator mien
      ---------------------------------
      Maarten L. Buis
      University of Konstanz
      Department of history and sociology
      box 40
      78457 Konstanz
      Germany
      http://www.maartenbuis.nl
      ---------------------------------

      Comment


      • #4
        Originally posted by Clyde Schechter View Post
        That limit of about 65,000 distinct values for a value label is absolute. The best you can do is to create an additional variable Mien_cat that reflects the category:

        Code:
        gen Mien_cat = "Failed" if Mien == -1
        replace Mien_cat = "Invalid" if Mien == -2
        replace Mien_cat = "Undetectable" if Mien == 0
        replace Mien_cat = "Suppressed" if inrange(Mien, 1, 1000)
        replace Mien_cat = "Unsuppressed" if inrange(Mien, 1001, 10000000)
        Thanks Clyde. Exactly what I did. Was checking to see if there was a better way out there. I even tried to create loops. Do you think using a while loop would help? I was thinking of using a loop that loops through the numeric variable until it gets to the end.

        Comment


        • #5
          No, there is nothing you can do to create a value label with more than 65,536 observations. A string variable like that is the best you can do.

          Comment


          • #6
            Originally posted by Maarten Buis View Post
            For problems like that, one typically creates a new variable, rather than giving lots of values the same label.

            Code:
            gen indicator = 1 if inrange(Result, 1, 1000)
            replace indicator = 0 if Result > 1000 & Result < .
            replace indicator = .a if Result == 0
            replace indicator = .b if Result == -1
            replace indicator = .c if Result == -2
            
            label define mien 1 "Suppressed" 2 "Unsuppressed" .a "Undetectable" .b "Failed" .c "Invalid"
            label value indicator mien
            Thanks Maarten. My inclination to want to save the world in one single code got me asking this question. Thanks. This is helpful. Regards

            Comment

            Working...
            X