Announcement

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

  • Copy value labels

    The function crcslbl can copy a variable's label to a new one. e.g. _crcslbl VariableA OldVariableA
    I need to copy the value label of the old variable into the new one.
    What is the STATA syntax for this?

  • #2
    Here's an old thread you may find helpful.
    --
    Bruce Weaver
    Email: [email protected]
    Version: Stata/MP 18.5 (Windows)

    Comment


    • #3
      Although I have no experience with - labmask -, I suspect this user-written program whose author is Nick Cox can do this trick for you.
      Best regards,

      Marcos

      Comment


      • #4
        I guess that you want one variable to be labelled according to the value labels of another. You could do that by using the name of the value labels in question or you can use macro extended function syntax to look up the value labels' name.

        Code:
        . clear 
        
        . set obs 2
        number of observations (_N) was 0, now 2
        
        . gen frog = _n 
        
        . label define mylabel 1 blue 2 red 
        
        . label val frog mylabel 
        
        . list 
        
             +------+
             | frog |
             |------|
          1. | blue |
          2. |  red |
             +------+
        
        . 
        . gen toad = 3 - frog 
        
        . label val toad mylabel 
        
        . list 
        
             +-------------+
             | frog   toad |
             |-------------|
          1. | blue    red |
          2. |  red   blue |
             +-------------+
        
        . 
        . label val toad 
        
        . list 
        
             +-------------+
             | frog   toad |
             |-------------|
          1. | blue      2 |
          2. |  red      1 |
             +-------------+
        
        . 
        . label val toad `: value label frog'
        
        . list 
        
             +-------------+
             | frog   toad |
             |-------------|
          1. | blue    red |
          2. |  red   blue |
             +-------------+

        Comment

        Working...
        X