Announcement

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

  • Change values without changing labels

    Hi,

    I have the following dataex for what I have a question about:
    Code:
    clear
    input int(H2PF1 H2PF8 H2PF4 H2PF9 H2PF5 H2PF10 H2PF11)
    . . . . . . .
    . . . . . . .
    . . . . . . .
    2 . 3 . 2 . 2
    . . . . . . .
    2 1 1 1 1 1 1
    2 2 2 2 2 2 1
    2 . 2 . 2 . 2
    3 . 3 . 3 . 3
    2 . 2 . 2 . 2
    1 . 1 . 1 . 1
    2 . 2 . 2 . 2
    2 . 2 . 1 . 1
    . . . . . . .
    1 . 2 . 1 . 1
    1 1 3 2 2 2 1
    1 1 2 2 1 1 1
    1 2 2 2 2 2 2
    . . . . . . .
    . . . . . . .
    2 2 2 3 2 2 2
    2 . 2 . 2 . 2
    2 . 3 . 4 . 2
    1 1 1 1 1 1 2
    2 . 2 . 2 . 2
    . . . . . . .
    1 . 1 . 2 . 2
    2 . 2 . 1 . 2
    1 . 1 . 1 . 1
    1 1 1 2 1 2 1
    1 2 1 2 1 2 2
    3 . 3 . 3 . 3
    3 . 3 . 3 . 3
    . 1 . 1 . 1 1
    1 2 1 2 1 2 1
    3 3 3 5 3 4 4
    2 2 3 2 3 2 2
    1 1 1 2 1 1 1
    . . . . . . .
    . . . . . . .
    2 . 1 . 1 . 1
    1 1 1 2 1 1 1
    1 2 1 2 1 2 2
    . . . . . . .
    2 1 5 1 2 2 2
    . . . . . . .
    2 2 2 2 2 2 3
    . . . . . . .
    2 . 3 . 1 . 1
    . . . . . . .
    . . . . . . .
    1 1 2 2 2 2 2
    2 2 4 4 4 2 3
    2 2 3 2 2 2 2
    2 . 3 . 2 . 4
    1 1 1 2 1 1 1
    . . . . . . .
    2 2 2 2 2 2 2
    1 1 1 1 1 1 2
    . . . . . . .
    2 . 2 . 2 . 2
    1 1 2 2 2 2 3
    1 . 1 . 1 . 1
    1 1 2 4 1 1 1
    1 1 2 1 1 1 2
    1 . 2 . 2 . 2
    1 . 2 . 2 . 2
    2 2 2 2 2 2 2
    1 1 1 1 1 1 1
    . . . . . . .
    3 2 4 2 4 1 1
    . . . . . . .
    1 1 1 1 1 1 1
    1 2 1 2 1 2 4
    . . . . . . .
    . . . . . . .
    2 1 1 1 1 1 1
    . . . . . . .
    . . . . . . .
    3 1 4 1 4 1 1
    2 1 1 1 1 1 1
    1 2 2 2 2 2 2
    4 3 4 2 4 2 2
    2 2 1 1 1 1 1
    . . . . . . .
    . 2 . 2 . 2 3
    . . . . . . .
    . . . . . . .
    . . . . . . .
    1 . 1 . 1 . 2
    . . . . . . .
    1 2 1 3 1 2 2
    1 2 2 2 1 2 1
    1 2 1 2 1 2 1
    2 2 2 2 2 2 2
    2 2 2 2 2 2 2
    . . . . . . .
    . . . . . . .
    . . . . . . .
    2 2 2 2 2 2 2
    end
    label values H2PF1 H2PF1
    label def H2PF1 1 "(1) Strongly agree", modify
    label def H2PF1 2 "(2) Agree", modify
    label def H2PF1 3 "(3) Neither agree nor disagree", modify
    label def H2PF1 4 "(4) Disagree", modify
    label values H2PF8 H2PF8
    label def H2PF8 1 "(1) Strongly agree", modify
    label def H2PF8 2 "(2) Agree", modify
    label def H2PF8 3 "(3) Neither agree nor disagree", modify
    label values H2PF4 H2PF4
    label def H2PF4 1 "(1) Strongly agree", modify
    label def H2PF4 2 "(2) Agree", modify
    label def H2PF4 3 "(3) Neither agree nor disagree", modify
    label def H2PF4 4 "(4) Disagree", modify
    label def H2PF4 5 "(5) Strongly disagree", modify
    label values H2PF9 H2PF9
    label def H2PF9 1 "(1) Strongly agree", modify
    label def H2PF9 2 "(2) Agree", modify
    label def H2PF9 3 "(3) Neither agree nor disagree", modify
    label def H2PF9 4 "(4) Disagree", modify
    label def H2PF9 5 "(5) Strongly disagree", modify
    label values H2PF5 H2PF5
    label def H2PF5 1 "(1) Strongly agree", modify
    label def H2PF5 2 "(2) Agree", modify
    label def H2PF5 3 "(3) Neither agree nor disagree", modify
    label def H2PF5 4 "(4) Disagree", modify
    label values H2PF10 H2PF10
    label def H2PF10 1 "(1) Strongly agree", modify
    label def H2PF10 2 "(2) Agree", modify
    label def H2PF10 4 "(4) Disagree", modify
    label values H2PF11 H2PF11
    label def H2PF11 1 "(1) Strongly agree", modify
    label def H2PF11 2 "(2) Agree", modify
    label def H2PF11 3 "(3) Neither agree nor disagree", modify
    label def H2PF11 4 "(4) Disagree", modify
    [/CODE]

    I want to keep the labels but change the values so that 1 would be low 'disagree' and 4 would be high 'agree'. How would I accomplish this?

    I am not sure whether this makes a difference or not but I have the following command:
    Code:
    alpha H2PF1 H2PF8 H2PF4 H2PF9 H2PF5 H2PF10 H2PF11, reverse(H2PF1 H2PF8 H2PF4 H2PF9 H2PF5 H2PF10 H2PF11) std gen(parentalattachment1)
    . The reverse code did not do what I was wanting it to.
    Last edited by kyle coran; 15 Mar 2023, 18:00.

  • #2
    You only need a single value label for all of the reversed variables:
    Code:
    label def new_label 5 "(5) Strongly agree" ///
        4 "(4) Agree" ///
        3 "(3) Neither agree nor disagree" ///
        2 "(2) Disagree" ///
        1 "(1) Strongly disagree"
        
    foreach v of varlist H2PF* {
        gen `v'_R:new_label = 6 - `v'
    }

    Comment


    • #3
      Originally posted by Clyde Schechter View Post
      You only need a single value label for all of the reversed variables:
      Code:
      label def new_label 5 "(5) Strongly agree" ///
      4 "(4) Agree" ///
      3 "(3) Neither agree nor disagree" ///
      2 "(2) Disagree" ///
      1 "(1) Strongly disagree"
      
      foreach v of varlist H2PF* {
      gen `v'_R:new_label = 6 - `v'
      }
      Would doing this just change the label of the reversed label or would it also transfer the correct frequency associated with each?

      Comment


      • #4
        I don't know what you mean by "transfer the correct frequency associated with each?" Here is what the code does (I show the results only for H2PF1--it is similar in all of the variables):

        Code:
        . label def new_label 5 "(5) Strongly agree" ///
        >     4 "(4) Agree" ///
        >     3 "(3) Neither agree nor disagree" ///
        >     2 "(2) Disagree" ///
        >     1 "(1) Strongly disagree"
        
        .     
        . foreach v of varlist H2PF* {
          2.     gen `v'_R:new_label = 6 - `v'
          3. }
        (33 missing values generated)
        (55 missing values generated)
        (33 missing values generated)
        (55 missing values generated)
        (33 missing values generated)
        (55 missing values generated)
        (31 missing values generated)
        
        .
        . tab1 H2PF1 H2PF1_R
        
        -> tabulation of H2PF1  
        
                                 H2PF1 |      Freq.     Percent        Cum.
        -------------------------------+-----------------------------------
                    (1) Strongly agree |         31       46.27       46.27
                             (2) Agree |         29       43.28       89.55
        (3) Neither agree nor disagree |          6        8.96       98.51
                          (4) Disagree |          1        1.49      100.00
        -------------------------------+-----------------------------------
                                 Total |         67      100.00
        
        -> tabulation of H2PF1_R  
        
                               H2PF1_R |      Freq.     Percent        Cum.
        -------------------------------+-----------------------------------
                          (2) Disagree |          1        1.49        1.49
        (3) Neither agree nor disagree |          6        8.96       10.45
                             (4) Agree |         29       43.28       53.73
                    (5) Strongly agree |         31       46.27      100.00
        -------------------------------+-----------------------------------
                                 Total |         67      100.00

        This is what I understood you to want. If I have misinterpreted your original question, it is unlikely that further attempts to explain it in words will resolve the problem. In that case, post back showing what you want the results to look like.

        Comment


        • #5
          Originally posted by Clyde Schechter View Post
          You only need a single value label for all of the reversed variables:
          Code:
          label def new_label 5 "(5) Strongly agree" ///
          4 "(4) Agree" ///
          3 "(3) Neither agree nor disagree" ///
          2 "(2) Disagree" ///
          1 "(1) Strongly disagree"
          
          foreach v of varlist H2PF* {
          gen `v'_R:new_label = 6 - `v'
          }
          Clyde, this is exactly what I wanted, I just misread the code you provided. It worked for that set, Thank you. I ran into an issue though when doing it for my othersets of variables "label new_label already defined". How would I address this issue?
          Last edited by kyle coran; 16 Mar 2023, 17:53.

          Comment


          • #6
            Sure. -foreach- is a command that creates a loop. The code within the curly braces it introduces is repeated. In this case, the repetitions correspond to the variables in your data set whose names match the H2PF* pattern, i.e. H2PF1, H2PF4, H2PF5, H2PF8, etc. The code between the braces will be carried out once for each of those variables. And in each repetition, the expression `v' that you see will be substituted by the name of the variable being currently processed.

            So the first time through the loop, `v' means H2PF1, and the code in between the braces translates to -gen H2PF1_R:new_label = 6 - H2PF1-. I assume you are familiar with the -gen- command, so I won't explain any part of that except for the :new_label part. That part just tells Stata that in creating the variable H2PF1_R, the value label called new_label, which was created in the code just above that, is to be attached to this new variable H2PF1_R. Now, just to be clear, 6 - H2PF1 will be 5 when H2PF1 itself is 1, 4 when H2PF2 is 2, etc.

            The -foreach- command comes in four different "flavors." Here we use the -foreach x of varlist list_of_variables- flavor. This is perhaps the most commonly used type of -foreach-. The general approach is just as it was here. The list of variables part can either be variables listed out one by one, or it can be a "wildcard expression" that abbreviates such a list (which is what H2PF* is). The x is an arbitrary name. I chose v because v reminds me of variable. But it could have been anything that is a legal name in Stata. Inside the loop, the value of x that is currently being processed is referred to by `x'. (This notation is the way Stata obtains the contents of a "local macro." I won't go into detail here about the more general properties and use of local macros. To use them with -foreach- you need only know what I have said to this point.)

            A second flavor of -foreach- is -foreach x of local name_of_a_local_macro-. Here there must already be another local macro that contains a list of things. The things might be variables, they might be numbers, names of matrices, whatever. The operation is the same. Again, x can be any legal name, and the current value of x being processed is referred to as `x'.

            A third flavor is -foreach x of numlist list_of_numbers-. Analogous to the previous versions, the commands between the curly braces are repeated, once for each number in the list of numbers, with `x' denoting the value of the number being currently processed. The list of numbers can be the numbers listed out one by one or grouped in certain ways. You can learn about the different ways to shorten number lists using number groups by reading -help numlist-.

            The fourth flavor is -foreach x in list_of_things -. Notice that this flavor uses in, not of. And what follows is a spelled out list of whatever you like. It operates in the same way as the others. There is one important thing to bear in mind about this flavor. With this one, you cannot use abbreviations, neither of lists of variables nor of lists of numbers: you must spell out the list one item at a time. And if you were to do something like -foreach x in H2PF*-, Stata would not expand H2PF* into the list of variables whose names begin with H2PF. Instead it would do the commands between the braces only once, and the only value of `x' that would be used would be the literal string "H2PF*". Now, there might be circumstances where you would want to do that, but they are unusual and probably only in fairly advanced Stata programming. If you did it with the command -gen `x' = 6 - `x'-, that would cause a syntax error. That's because during execution that command would be spelled out as -gen H2PF* = 6 - H2PF*-. And that's illegal because in both places where H2PF* appears, Stata requires a single variable only, not a list.

            There are a couple of other ways to create loops in Stata that do not use -foreach-. They are less commonly used.
            Last edited by Clyde Schechter; 16 Mar 2023, 18:04.

            Comment


            • #7
              That makes perfect sense. Would I be able to use that same code for my other sets of variables?

              Comment


              • #8
                You could adapt the code. You would need to change the -foreach- command to provide the list (or wildcard abbreviation of a list) of variables involved. If the variables in question have the same response set as the ones in #1, then that is all you would need to change. But if the response set is different, you might have to create a different new label, and, if it is not 1, 2, 3, 4, 5 then 6-`v' will have to be replaced by a different formula that is appropriate to those numbers.

                Comment


                • #9
                  Code:
                  replace H2PF1 = . if H2PF1 == 6 | H2PF1 == 7 | H2PF1 == 8
                  replace H2PF8 = . if H2PF8 == 6 | H2PF8 == 7 | H2PF8 == 8
                  replace H2PF4 = . if H2PF4 == 6 | H2PF4 == 7 | H2PF4 == 8
                  replace H2PF9 = . if H2PF9 == 6 | H2PF9 == 7 | H2PF9 == 8
                  replace H2PF5 = . if H2PF5 == 6 | H2PF5 == 7 | H2PF5 == 8
                  replace H2PF10 = . if H2PF10 == 6 | H2PF10 == 7 | H2PF10 == 8
                  replace H2PF11 = . if H2PF11 == 6 | H2PF11 == 7 | H2PF11 == 8
                  generate pattachment = H2PF1 + H2PF8 + H2PF4 + H2PF9 + H2PF5 + H2PF10 + H2PF11
                  alpha H2PF1 H2PF8 H2PF4 H2PF9 H2PF5 H2PF10 H2PF11, item
                  
                  label def attachment_label 5 "(5) Strongly agree" ///
                  4 "(4) Agree" ///
                  3 "(3) Neither agree nor disagree" ///
                  2 "(2) Disagree" ///
                  1 "(1) Strongly disagree"
                  
                  foreach v of varlist H2PF* {
                  gen `v'_R:attachment_label = 6 - `v'
                  }
                  tab1 H2PF8 H2PF8_R
                  Clyde, I want to compute the sums and correlations of the 7 H2PF* variables before and after foreach and am struggling to figure out how to do so. I generated a new variable for attachment prior to the reverse that I labeled 'pattachment'. I figured that after running the foreach command I could use the command
                  Code:
                  generate attachment = H2PF1_R H2PF4_R H2PF9_R H2PF5_R H2PF10_R H2PF11_R H2PF8_R
                  but it gives me the error 'invalid 'H2PF4_R'. I can send a dataex if you need.

                  OR is there a different command that can be used that can reverse the labels as well as the frequency. I had used the revrs option previously but ran into a frequency issue:
                  Code:
                  S18Q11 TELL PARENTS WHERE ON |
                                     WEEKENDS-W2 |      Freq.     Percent        Cum.
                  -------------------------------+-----------------------------------
                              (1) Strongly agree |      2,194       46.75       46.75
                                       (2) Agree |      1,902       40.53       87.28
                  (3) Neither agree nor disagree |        324        6.90       94.18
                                    (4) Disagree |        218        4.65       98.83
                           (5) Strongly disagree |         55        1.17      100.00
                  -------------------------------+-----------------------------------
                                           Total |      4,693      100.00
                   tab revH2PF11
                  
                    S18Q11 TELL PARENTS WHERE ON |
                                     WEEKENDS-W2 |      Freq.     Percent        Cum.
                  -------------------------------+-----------------------------------
                           (5) Strongly disagree |         55        1.17        1.17
                                    (4) Disagree |        218        4.65        5.82
                  (3) Neither agree nor disagree |        324        6.90       12.72
                                       (2) Agree |      1,902       40.53       53.25
                              (1) Strongly agree |      2,194       46.75      100.00
                  -------------------------------+-----------------------------------
                                           Total |      4,693      100.00
                  where I want the frequency to be associated with the correct label. Ex: for revH2PF11: frequency to be 2,194 not 55.
                  Last edited by kyle coran; 17 Mar 2023, 18:54.

                  Comment


                  • #10
                    You seem to have several things going on here.

                    Creating a variable as the sum of the H2PF* variables by adding them up seems sensible, until you consider that you have some missing values in your data. When any of those H2PF* values is missing, the sum, computed in that way will also be missing. So it is better to use -egen, rowtotal()-, which will ignore the missing values. You also speak of getting the correlations among the variables--but you have not used any correlation command. -alpha- is for computing Cronbach's alpha, and while that does derive from correlations among the variables, it is rather different. Here's code that will get what you have said you want.

                    Code:
                    egen sum_before = rowtotal(H2PF*)
                    pwcorr H2PF*
                    
                    label def new_label 5 "(5) Strongly agree" ///
                        4 "(4) Agree" ///
                        3 "(3) Neither agree nor disagree" ///
                        2 "(2) Disagree" ///
                        1 "(1) Strongly disagree"
                        
                    foreach v of varlist H2PF* {
                        gen `v'_R:new_label = 6 - `v'
                    }
                    
                    egen sum_after = rowtotal(H2PF*_R)
                    pwcorr H2PF*_R
                    You will notice that the correlations are exactly the same before and after the reversal, which is what you should expect. The sums are related, too. Since each observation after is just 6 - the original observation, the second sum will equal (6*# of non-missing H2PF variables) - (sum of H2PF variables).

                    That said, you have to be very careful using a variable defined as the sum of other variables when there is missing data. Using the total in this way treats each missing response as if it were a 0 response. Well, 0 isn't even a valid response. But if it were, in the H2PF* variables it would mean something like super-strongly agree, whereas in the H2PF_R* variables it would mean something like super-strongly disagree. So the missing values have diametrically opposite meanings in the two sets of variables, and yet they are numerically the same (missing value, but treated as zero). And the sum, in each case, effectively imputes an extreme response in one direction to any non-responded item. This is really rather a bad situation: the sum is really an incoherent construct.

                    If you are trying to create some kind of scale score out of these variables, it is better to use the mean. -egen- has a -rowmean()- function that will do this for you. Missings are ignored, but in the setting of calculating a mean, because missing reduce both the numerator and the denominator, missing values truly do not affect the resulting score at all. This is a much better approach.

                    Comment


                    • #11
                      Hi Clyde, I once again messed up on what I was saying. I meant to say the mean and not the sum. I was able to gather the mean but I fear that I am doing something incorrect.

                      Code:
                      //option 1
                      generate parentalattachment = H2PF1 + H2PF8 + H2PF4 + H2PF9 + H2PF5 + H2PF10 + H2PF11
                      /*
                      //option 2
                      alpha H2PF1 H2PF8 H2PF4 H2PF9 H2PF5 H2PF10 H2PF11, generate(parentalattachment) item
                      */
                      
                      
                      label def attachment_label 5 "(5) Strongly agree" ///
                      4 "(4) Agree" ///
                      3 "(3) Neither agree nor disagree" ///
                      2 "(2) Disagree" ///
                      1 "(1) Strongly disagree"
                      ///these shoukd be - correl w delinq
                      foreach v of varlist H2PF* {
                      gen `v'_R:attachment_label = 6 - `v'
                      }
                      
                      //option 1
                      generate attachment = H2PF1_R + H2PF8_R + H2PF4_R + H2PF9_R + H2PF5_R + H2PF10_R + H2PF11_R
                      /*
                      //option 2
                      alpha H2PF1_R H2PF8_R H2PF4_R H2PF9_R H2PF5_R H2PF10_R H2PF11_R, generate(attachment) item
                      */
                      My goal in the above code was to try two different options to gather what I need for my work. I don't think explaining it is particularly necessary but I can if it will help it be less confusing. My concern is that when I ran both the generate and the alpha command (separately) I came up with the same issue for both where after reversing my variables with the -foreach- command the frequency of my value options changed as well as my min and max. I have attached what I am talking about where prior to reversing (parentalattachment is the before reverse) my range was 7-34 and after reversing (attachment is the after reverse) my range was 8-35.

                      Along with this, my frequency changed where 7 used to be 481 and 34 was 1, 8 has become 1 and 35 has become 481. If possible, would you be able to tell me what mistake I am making here?

                      Code:
                       attachment |      Freq.     Percent        Cum.
                      ------------+-----------------------------------
                                8 |          1        0.03        0.03
                                9 |          4        0.12        0.15
                               10 |          2        0.06        0.21
                               12 |          3        0.09        0.30
                               13 |          5        0.15        0.45
                               14 |          8        0.24        0.69
                               15 |          5        0.15        0.84
                               16 |         15        0.45        1.30
                               17 |         18        0.54        1.84
                               18 |         18        0.54        2.38
                               19 |         32        0.97        3.35
                               20 |         33        1.00        4.34
                               21 |         60        1.81        6.15
                               22 |         71        2.14        8.29
                               23 |         76        2.29       10.59
                               24 |        122        3.68       14.26
                               25 |        115        3.47       17.73
                               26 |        172        5.19       22.92
                               27 |        229        6.91       29.83
                               28 |        463       13.96       43.79
                               29 |        266        8.02       51.81
                               30 |        227        6.85       58.66
                               31 |        225        6.79       65.44
                               32 |        197        5.94       71.38
                               33 |        190        5.73       77.11
                               34 |        278        8.38       85.49
                               35 |        481       14.51      100.00
                      ------------+-----------------------------------
                            Total |      3,316      100.00
                      Code:
                      parentalatt |
                          achment |      Freq.     Percent        Cum.
                      ------------+-----------------------------------
                                7 |        481       14.51       14.51
                                8 |        278        8.38       22.89
                                9 |        190        5.73       28.62
                               10 |        197        5.94       34.56
                               11 |        225        6.79       41.34
                               12 |        227        6.85       48.19
                               13 |        266        8.02       56.21
                               14 |        463       13.96       70.17
                               15 |        229        6.91       77.08
                               16 |        172        5.19       82.27
                               17 |        115        3.47       85.74
                               18 |        122        3.68       89.41
                               19 |         76        2.29       91.71
                               20 |         71        2.14       93.85
                               21 |         60        1.81       95.66
                               22 |         33        1.00       96.65
                               23 |         32        0.97       97.62
                               24 |         18        0.54       98.16
                               25 |         18        0.54       98.70
                               26 |         15        0.45       99.16
                               27 |          5        0.15       99.31
                               28 |          8        0.24       99.55
                               29 |          5        0.15       99.70
                               30 |          3        0.09       99.79
                               32 |          2        0.06       99.85
                               33 |          4        0.12       99.97
                               34 |          1        0.03      100.00
                      ------------+-----------------------------------
                            Total |      3,316      100.00

                      Comment


                      • #12
                        The code you are showing does not calculate means. It calculates sums, and, as I have previously said, doing this with -generate parentalattachment = H2PF1 + H2PF8 + H2PF4 + H2PF9 + H2PF5 + H2PF10 + H2PF11- is a treacherous way to do that because observations with any missing value among the variables will result in a missing value for the sum. And getting around this by using -egen, rowtotal()- would result in treating the missing values as if they were zero responses. That, in turn, is even more treacherous, because 0 is not a valid response, and, if interpreted as if it were, it would be a more extreme response than any. The appropriate way to create an index is with -egen, rowmean()-. I've said that earlier in this thread, and I stand by it.

                        That said, even using your approach with adding up the variables, the only thing wrong with what you set out in #11 is your expectation that the values and ranges of the two indices should be the same. There is no basis for that. Let's take a very simplified case. Suppose there were only a single H2PF item. There is no reason to think that H2PF_R would have the same values and range as H2PF. However many 1 responses in H2PF, there would be the same number of 5 responses in H2PF_R. However many 2 responses in H2PF, there would be the same number of 4 responses in H2PF_R. If the range of responses to H2PF were from 1 through 4, then the range of responses in H2PF_R would be 2 through 5. The same remains true as you add more variables in.

                        If you follow my advice and generate the indices using -egen, rowmean()-, then the complications introduced by missing values are avoided. Moreover, the relationship between the values of the index and the values of the index reversed becomes simple: each is equal to six minus the other.

                        Code:
                        egen double pattachment = rowmean(H2PF*)
                        
                        label def new_label 5 "(5) Strongly agree" ///
                            4 "(4) Agree" ///
                            3 "(3) Neither agree nor disagree" ///
                            2 "(2) Disagree" ///
                            1 "(1) Strongly disagree"
                            
                        foreach v of varlist H2PF* {
                            gen `v'_R:new_label = 6 - `v'
                        }
                        
                        egen double pattachment_R = rowmean(H2PF*_R)
                        
                        assert pattachment + pattachment_R == 6 if !missing(pattachment)
                        
                        tab pattachment pattachment_R

                        Comment

                        Working...
                        X