Announcement

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

  • Issue relabeling variables

    Dear all,

    I am working on cleaning my data set, but have been troubels with relabeling some of my variables.

    1. First of all, I wanted to relabel some variables to create a more intutive scale. I wanted to go from 3 "Strongly Agree" 2 "Agree" 1 "Disagree" 0 "Strongly Disagree" to 0 "Strongly Agree" 1 "Agree" 2 "Disagree" 3 "Strongly Disagree" which I tried to do as followed (see below). This did not work, as the labels were redefined but the count of responses was not correct anymore, as it seemed that the labels did indeed change but the response count did not. So it seemed that now the label Strongly Disagree was connected to the beneficiaries whom answered strongly agree. See my steps below.


    Code:
     
    label define likertnew 0 "Strongly Agree" 1 "Agree" 2 "Disagree" 3 "Strongly Disagree"
    label values male_stypes1 likertnew
    label values male_stypes2 likertnew
    label values male_stypes3 likertnew
    label values male_stypes4 likertnew
    
    *I had the same relabeling problem with creating new labels for stereotypes female which is connected to the same value label. I tried the following
    label values wea_stypes1 likertnew
    label values wea_stypes2 likertnew
    label values wea_stypes3 likertnew
    label values wea_stypes4 likertnew
    2. Next to that, I tried to combine some value labels as I wanted to create 3 answer options instead of 4 by combining two answer options under one label. Under the original value label there were 4 options 1 myself and my husband 2 my husband 3 myself and 4 someone else in the household. I want to create 1 "Someone else in the family " 2 "My husband " 3 "Myself" 3 "Myself and my husband jointly" however this does not seem to work. I did the below.

    Code:
    label define decisionnew 1 "Someone else in the family " 2 "My husband " 3 "Myself" 3 "Myself and my husband jointly"



  • #2
    Hello Linda. If I follow, you would need to reverse-code the items in addition to assigning the new value labels. See the following example. HTH.

    Code:
    // Generate some data to illustrate
    clear
    input byte(v1 n)
    0 5
    1 10
    2 15
    3 20
    end
    expand n
    // Create the original value labels
    label define original ///
     3 "Strongly Agree" 2 "Agree" 1 "Disagree" 0 "Strongly Disagree"
    label values v1 original
    *ssc install fre // Uncomment to install -fre- if necessary
    fre v1
    // What Linda did
    label define newlabs ///
     0 "Strongly Agree" 1 "Agree" 2 "Disagree" 3 "Strongly Disagree"
    label values v1 newlabs
    fre v1
    // NOTE:  This just changes the LABELS.
    // I believe Linda really wants to reverse-code the items.
    // If so, it is good practice to reverse-code into new variables.
    // First, restore the original value labels for v1.
    label values v1 original
    fre v1
    // Let v1rev = reverse-coded v1
    generate byte v1rev = 3-v1
    // Assign the new value labels to v1rev
    label values v1rev newlabs
    // Check that it worked as expected
    fre v1 v1rev
    --
    Bruce Weaver
    Email: [email protected]
    Version: Stata/MP 18.5 (Windows)

    Comment


    • #3
      Also, see elabel (from GitHib or SSC).

      To reverse the label and recode all variables that have the label attached

      Code:
      elabel recode lblname (3/0 = 0/3) , recodevarlist

      Comment


      • #4
        Thank you both!
        Daniel when I try elabel recode I get an error message?
        Code:
        elabel recode lblLIKERT (3/0 = 0/3), recodevarlist
        option recodevarlist not allowed
        r(198);


        Am I doing something wrong?

        Comment


        • #5
          You probably have an outdated version. Where did you download elabel?

          When you type

          Code:
          which elabel
          you need at least

          Code:
          (output omitted)
          *! version 4.3.1 20oct2021

          Edit:

          Download elabel from SSC or GitHub; the latter hosts the most recent version.
          Last edited by daniel klein; 15 Oct 2022, 07:58.

          Comment


          • #6
            Hi Daniel,

            I have seemed to have fixed the likert scale one. Now I am only struggeling with the decision making one, as something seems to go wrong when I want to aggregate Next to that, I tried to combine some value labels as I wanted to create 2 answer options (not 3 as said above) instead of 4 by combining two answer options under one label. Under the original value label there were 4 options 1 myself and my husband 2 my husband 3 myself and 4 someone else in the household. I want to create 0 "Someone else in the family " 0 "My husband " 1 "Myself" 1 "Myself and my husband jointly" however this does not seem to work. The objective for this is that I can create an index from 0 - 8 depending on the answers of the beneficiaries.

            I tried to do it like this
            Code:
            recode wea_dec_1 wea_dec_2 wea_dec_3 wea_dec_4 wea_dec_5 wea_dec_6 wea_dec_7 wea_dec_8 (2 4=0) (1 3=1)

            Comment


            • #7
              Which outcome were you expecting? Which outcome did you obtain?

              Nothing in the recode command above does anything to the value labels. You cannot attach multiple labels to the same integer value.

              You seem to want to define entirely new value labels. That is fine, but there is no shortcut here. You need to spell things out. Perhaps you want something like

              Code:
              recode varlist (2 4 = 0 "Someone else/husband") (1 3 = 1 "Myself (with hsband)") , prefix(r_) label(decisionnew)

              Comment


              • #8
                This seemed to have worked! Thanks Daniel for the quick reply

                Comment

                Working...
                X