Announcement

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

  • Certain value labels do not survive frlink

    Hi all,

    I am experiencing something puzzling.

    I have two frames (frame1 and frame2), each indexed by a variable index. frame1 contains two other variables, dummy1 and dummy2. The two dummies each are labels with value labels mapping 1 to "Yes" and 0 to "No". The value labels are named differently.

    When I use frlink to access the dummy variables from frame1 in frame2, only one of the value labels persists, and it is applied to both variables. This behavior does not occur with the traditional merge command. Does anyone know why this occurs with frlink?

    The below code suffices to demonstrate what I mean, and the screengrab shows that the value labels are changed.

    Code:
    mkf frame1
    frame frame1 {
        set obs 3
        gen byte index = _n
        gen byte dummy1 = index > 1
        gen byte dummy2 = index < 3
    
        label define dummy1label 0 "No" 1 "Yes"
        label define dummy2label 0 "No" 1 "Yes"
        label values dummy1 dummy1label
    
        label values dummy2 dummy2label
        describe
    }
    mkf frame2
    frame frame2 {
        set obs 3
        gen byte index = _n
        frlink 1:1 index, frame(frame1)
        frget dummy1 dummy2, from(frame1)
        describe
    }
    Click image for larger version

Name:	Capture.PNG
Views:	2
Size:	245.7 KB
ID:	1751390


    Attached Files

  • #2
    I am able to replicate this on my setup as well. (Stata 18 MP4, Windows 64-bit) I can't imagine this is anything other than a bug. Interestingly, however, if the content of dummy2label is different from that of dummy1label in frame1, Stata does then pick up both labels, even though the modification to the label does not apply to any instantiated values:
    Code:
    . clear*
    
    . mkf frame1
    
    . frame frame1 {
    .     set obs 3
    Number of observations (_N) was 0, now 3.
    .     gen byte index = _n
    .     gen byte dummy1 = index > 1
    .     gen byte dummy2 = index < 3
    .
    .     label define dummy1label 0 "No" 1 "Yes"
    .     label define dummy2label 0 "No" 1 "Yes" 2 "Who knows?"
    .     label values dummy1 dummy1label
    .
    .     label values dummy2 dummy2label
    .     describe
    
    Contains data
     Observations:             3                  
        Variables:             3                  
    -------------------------------------------------------------------------------------------------------------------------------------
    Variable      Storage   Display    Value
        name         type    format    label      Variable label
    -------------------------------------------------------------------------------------------------------------------------------------
    index           byte    %8.0g                
    dummy1          byte    %8.0g      dummy1label
                                                  
    dummy2          byte    %10.0g     dummy2label
                                                  
    -------------------------------------------------------------------------------------------------------------------------------------
    Sorted by:
         Note: Dataset has changed since last saved.
    . }
    
    . mkf frame2
    
    . frame frame2 {
    .     set obs 3
    Number of observations (_N) was 0, now 3.
    .     gen byte index = _n
    .     frlink 1:1 index, frame(frame1)
    (all observations in frame frame2 matched)
    .     frget dummy1 dummy2, from(frame1)
    (2 variables copied from linked frame)
    .     describe
    
    Contains data
     Observations:             3                  
        Variables:             4                  
    -------------------------------------------------------------------------------------------------------------------------------------
    Variable      Storage   Display    Value
        name         type    format    label      Variable label
    -------------------------------------------------------------------------------------------------------------------------------------
    index           byte    %8.0g                
    frame1          byte    %10.0g                
    dummy1          byte    %8.0g      dummy1label
                                                  
    dummy2          byte    %10.0g     dummy2label
                                                  
    -------------------------------------------------------------------------------------------------------------------------------------
    Sorted by:
         Note: Dataset has changed since last saved.
    . }
    
    .
    I suggest you send this on to Stata Technical Support.

    Comment


    • #3
      Clyde, I appreciate your replicating this behavior. I will get in touch with Stata Technical Support, as you suggested.

      Comment

      Working...
      X