Announcement

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

  • Duplicate variable labels

    Dear all,

    My dataset contains at least 5000 variables from PSID and variable names are not consistent across waves. I am using lab2varn to use variable labels as variable names to have unique names. Some of the variables have the same labels and hence lab2varn gives an error. Is there a way to find those variables with the same labels and make changes to them at once? I do not wish to do it manually, so any help would be appreciated.

    Best,

  • #2
    I guess daniel klein has posted on this somewhere. Otherwise here is a quick and dirty utility to detect groups of variables with the same variable label. Note that same is literal: cosmetic differences involving spaces, other punctuation or upper and lower case are not ignored.

    There is no data example in #1. So, I created a silly sandbox in which there are two groups of two variables with the same variable label.

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input byte(frog toad newt crocodile alligator) 
    1 1 1 1 1 
    end
    label var frog "frog" 
    label var toad "frog" 
    label var newt "newt" 
    label var crocodile "crocodile"
    label var alligator "crocodile"
    
    describe 
    
    samevarlabels 
    
    macro list
    Here are the results, except that I have edited out the display of various macros nothing to do with the problem.


    Code:
    . * Example generated by -dataex-. For more info, type help dataex
    . clear
    
    . input byte(frog toad newt crocodile alligator) 
    
             frog      toad      newt  crocod~e  alliga~r
      1. 1 1 1 1 1 
      2. end
    
    . label var frog "frog" 
    
    . label var toad "frog" 
    
    . label var newt "newt" 
    
    . label var crocodile "crocodile"
    
    . label var alligator "crocodile"
    
    . 
    . describe 
    
    Contains data
     Observations:             1                  
        Variables:             5                  
    ---------------------------------------------------------------------------------------------------------------
    Variable      Storage   Display    Value
        name         type    format    label      Variable label
    ---------------------------------------------------------------------------------------------------------------
    frog            byte    %8.0g                 frog
    toad            byte    %8.0g                 frog
    newt            byte    %8.0g                 newt
    crocodile       byte    %8.0g                 crocodile
    alligator       byte    %8.0g                 crocodile
    ---------------------------------------------------------------------------------------------------------------
    Sorted by: 
         Note: Dataset has changed since last saved.
    
    . 
    . samevarlabels 
    
         +-------------------------------+
         |   varname    varlabel   group |
         |-------------------------------|
      1. | alligator   crocodile       1 |
      2. | crocodile   crocodile       1 |
         |-------------------------------|
      3. |      frog        frog       2 |
      4. |      toad        frog       2 |
         +-------------------------------+
    alligator crocodile
    frog toad
    
    . 
    . macro list 
    
    _samevl2:       frog toad
    _samevl1:       alligator crocodile
    _samevlgroups:  2
    So, there is some redundancy of output, intended to be helpful:

    1. Lists of groups of variables with the same variable label in a list.

    2. The same as displayed by calls to levelsof.

    3. The same as included in local macros accessible when the program finishes.

    Here is the code for a program which should be saved as samevarlabels.ado in PLUS along your adopath.

    Code:
    *! 1.0.0 NJC 19 July 2022 
    program samevarlabels  
        version 9 
        syntax [varlist] 
        quietly ds `varlist', has(varlabel)
        local varlist "`r(varlist)'"
        
        tempname whatever 
        tempfile varinfo 
        postfile `whatever' str32 varname str80 varlabel using `varinfo'
        
        foreach v of local varlist {
            local thislabel : var label `v'
            post `whatever' ("`v'") (`"`thislabel'"') 
        }
    
        postclose `whatever' 
        
        preserve 
        
        use "`varinfo'", clear 
        quietly bysort varlabel : drop if _N == 1 
        egen group = group(varlabel)
        list, sepby(group)
    
        su group, meanonly 
        c_local samevlgroups = r(max) 
        forval g = 1/`r(max)' { 
            levelsof varname if group == `g', local(samevl`g') clean 
            c_local samevl`g' "`samevl`g''"  
        } 
    end

    Comment


    • #3
      Perhaps surprisingly, I do not recall having tackled this particular problem. Nick's code is good. You could bypass the postfile part using describe with the replace option.

      Comment


      • #4
        Goodness yes! Here is a rewrite following Daniel klein's suggestion.


        Code:
        *! 2.0.0 NJC 19 July 2022 using daniel klein suggestion 
        *! 1.0.0 NJC 19 July 2022 
        program samevarlabels  
            version 17 
            syntax [varlist] 
            quietly ds `varlist', has(varlabel)
        
            preserve 
            keep `r(varlist)'
            describe, replace clear 
            keep name varlab 
            quietly bysort varlab : drop if _N == 1 
            egen group = group(varlab)
            list, sepby(group)
        
            su group, meanonly 
            c_local samevlgroups = r(max) 
            forval g = 1/`r(max)' { 
                levelsof name if group == `g', local(samevl`g') clean 
                c_local samevl`g' "`samevl`g''"  
            } 
        end
        ​​​​​​​

        Comment


        • #5
          Thank you so very much! I appreciate the help.

          Best

          Comment


          • #6
            Hello Nick Cox ,

            Thank you again for the solution. I followed your instructions and ran the code. It worked perfectly. I do have a follow-up question. I would like to make changes to the labels. For instance, for the variable frog, I wish to have two different labels like “frog_1” or “frog_2” (or even “frog_3 if there are 3 variables with the “frog” label). The idea is to then use lab2varn to rename all the variables using their distinct labels. I have attached part of the result I obtained using your code on my dataset. There are around 200 different variables with the same labels (sometimes even 4 variables with the same labels). I believe changing the labels manually will be difficult. Could you guide me over this?

            The final goal is to have distinct labels for all the variables so that I can use lab2varn.
            Click image for larger version

Name:	duplicated_var_labels.PNG
Views:	1
Size:	113.6 KB
ID:	1675082



            Thank you for your time and consideration.
            Last edited by Aman Ojas Desai; 25 Jul 2022, 21:01.

            Comment


            • #7
              Here is one approach using Nick's command:

              Code:
              // get groups of duplicate variable labels
              samevarlabels
              
              // loop over groups of duplicate variable labels
              forvalues i = 1/`samevlgroups' {
                  // get variable label for the group
                  local fistvar  : word 1 of `samevl`i''
                  local varlabel : variable label `fistvar'
                  // make it a valid variable name
                  local newname = strtoname(`"`varlabel'"')
                  // rename group of variables
                  rename (`samevl`i'') (`newname'#) , addnumber
              }
              The code will fail if implied variable labels exceed 32 characters.


              Some words of caution.

              Even if variable labels do not exceed 32 characters, variable labels (with invalid characters for names removed) usually imply awkward variable names that are unpleasant to read and hard to type. For example, consider the following names implied in #6:

              Code:
              __FEM_CHILDS_14_171
              __FEM_CHILDS_14_172
              I am not convinced that this is a good solution.

              Moreover, for this approach to solve the problem stated in #1, one needs to assume that variable labels are consistent across datasets when variable names are not; I do not think this is likely to be the case. And, even if it were so, there is no way that duplicate labels can be used to combine corresponding variables because combining corresponding variables requires unique identification of the variables to be combined. The approach above does not solve this problem. Nick's command puts the variable names with the same variable label in the alphanumeric order of their names. Thus, adding a number to those labels to make the names unique works in one dataset but will not be content across datasets. That is, V8717 might be renamed to __FEM_CHILDS_14_171 in one dataset but the corresponding variable in another dataset might get renamed to __FEM_CHILDS_14_172.

              Executive summary: Rephrase your ultimate goal and the initial problem that you think needs solving to achieve this goal. Do not proceed in the direction you are heading now. You will mess up and probably will not even realize it.
              Last edited by daniel klein; 26 Jul 2022, 00:47.

              Comment


              • #8
                Re-reading #1, it appears that you have already combined different (waves of) datasets. In that case, you are trying to fix things that are probably not relevant to your problem. Because you have not shown any data example, I have to guess here; I am guessing that your data looks like something like this:

                Code:
                . describe
                
                Contains data
                 Observations:            10                  
                    Variables:             2                  
                -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
                Variable      Storage   Display    Value
                    name         type    format    label      Variable label
                -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
                V1              float   %9.0g                 # FEM CHILDS 14-17
                V2              float   %9.0g                 # FEM CHILDS 14-17
                -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
                Sorted by:
                     Note: Dataset has changed since last saved.
                
                . list
                
                     +---------+
                     | V1   V2 |
                     |---------|
                  1. |  2    . |
                  2. |  3    . |
                  3. |  0    . |
                  4. |  3    . |
                  5. |  0    . |
                     |---------|
                  6. |  .    2 |
                  7. |  .    0 |
                  8. |  .    3 |
                  9. |  .    1 |
                 10. |  .    3 |
                     +---------+
                Here, V1 and V2 have the same label but different names. Does this resemble your dataset? If so, I do not see how changing the names V1 and V2 to __FEM_CHILDS_14_171 and __FEM_CHILDS_14_172 does anything useful for you. You probably want to fill the missing values in one variable with the non-missing values in the other(s).

                I will stop there because there is just too much guessing involved. See executive summary in my previous answer and rephrase your ultimate goal, providing a data example of your problem.

                Comment


                • #9
                  Hello daniel klein ,

                  Thank you very much for the solution. I am grateful for the executive summary. Let me explain what I intend to do here. I wish to include all the variables in the PSID individual as well as family files for certain cohorts (born in 1980-1982). The idea is to use that data (using ML methods as it will be a big data set) to predict their future labor market outcomes in 2019. The whole project rests on the fact that I am not arbitrarily choosing variables from the PSID data.

                  As you know, the PSID variable names are not consistent, nor do they have any patterns. So, my purpose is to
                  do the following:
                  1. Rename the variables using their labels. I intend to use lab2varn for that. The labels have to be distinct for all the variables to use lab2varn, hence the original question.
                  2. After making sure that I have distinct variable names, I wish to rename the variables such that they are in the form of “stub_##”, where ## corresponds to the particular wave. I will use -rename group- for that by following some rules. Having done that, I wish to reshape the data from wide to long.

                  Since there will be at least 5000 variables in the whole data set, it will be difficult to manually go over the required variables. (It should not even matter as this will be a predictive analysis exercise instead of causal analysis)

                  I am attaching a part of the dataset as an example of my analytical sample. I will be very grateful to receive your input.

                  Alternatively, is it okay to just run the prediction exercise on wide data (will it matter whether the data is in the wide or long format as it is just a predictive analysis)?

                  Thank you so much for your time and consideration.

                  Best,


                  * Example generated by -dataex-. For more info, type help dataex
                  clear
                  input byte V6958 float V7066 byte(V7070 V7550) float(V7610 V7613 V7616 V7619 V7622 V7657) byte(V7661 V8090 V8091 V8092 V8093 V8095 V8097 V8248) float V8351 byte(V8355 V8714 V8715 V8716)
                  2 2 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 1 0 0 0 0
                  2 2 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 . . . . . .
                  2 2 0 . . . . . . . . . . . . . . . . . . . .
                  2 3 1 2 0 0 0 0 0 3 1 0 0 0 0 0 0 2 4 1 0 0 0
                  2 3 1 2 0 0 0 0 0 3 1 0 0 0 0 0 0 2 4 1 0 0 0
                  2 4 2 2 0 0 0 0 0 4 2 0 0 2 0 0 0 2 4 2 0 0 2
                  2 4 2 2 0 0 0 0 0 4 2 1 1 0 0 0 0 2 4 2 0 2 0
                  2 4 2 2 0 0 0 0 0 4 2 0 1 1 0 0 0 2 4 2 0 0 2
                  2 3 1 . . . . . . . . . . . . . . 2 4 1 0 0 0
                  2 3 1 2 0 0 0 0 0 3 1 0 0 0 0 0 0 2 4 1 0 0 0
                  2 4 2 2 0 0 0 0 0 4 2 0 0 2 0 0 0 2 4 2 0 0 2
                  2 4 2 2 0 0 0 0 0 4 2 0 1 1 0 0 0 2 4 2 0 0 2
                  2 4 2 2 0 0 0 0 0 4 2 0 0 2 0 0 0 2 4 2 0 0 2
                  2 4 2 2 0 0 0 0 0 4 2 0 1 1 0 0 0 2 4 2 0 0 2
                  2 4 2 2 0 0 0 0 0 4 2 1 1 0 0 0 0 2 4 2 0 2 0
                  2 4 2 2 0 0 0 0 0 4 2 1 1 0 0 0 0 2 4 2 0 2 0
                  2 3 1 . . . . . . . . . . . . . . 2 4 1 0 0 0
                  2 4 2 2 0 0 0 0 0 4 2 0 0 2 0 0 0 2 4 2 0 0 2
                  2 4 2 2 0 0 0 0 0 4 2 0 1 1 0 0 0 2 4 2 0 0 2
                  2 4 2 2 0 0 0 0 0 4 2 0 0 2 0 0 0 2 4 2 0 0 2
                  2 4 2 2 0 0 0 0 0 4 2 0 0 2 0 0 0 2 4 2 0 0 2
                  2 3 1 2 0 0 0 0 0 3 1 0 0 0 0 0 0 2 4 1 0 0 0
                  2 3 1 2 0 0 0 0 0 3 1 0 0 0 0 0 0 2 4 1 0 0 0
                  2 4 2 2 0 0 0 0 0 4 2 0 0 2 0 0 0 2 4 2 0 0 2
                  2 4 2 2 0 0 0 0 0 4 2 0 0 2 0 0 0 2 4 2 0 0 2
                  2 3 1 2 0 0 0 0 0 3 1 0 0 0 0 0 0 2 4 1 0 0 0
                  2 4 2 2 0 0 0 0 0 4 2 0 0 2 0 0 0 2 4 2 0 0 2
                  2 4 2 2 0 0 0 0 0 4 2 0 1 1 0 0 0 2 4 2 0 0 2
                  2 4 2 2 0 0 0 0 0 4 2 1 1 0 0 0 0 2 4 2 0 2 0
                  2 4 2 2 0 0 0 0 0 4 2 0 0 2 0 0 0 2 4 2 0 0 2
                  2 3 1 2 0 0 0 0 0 3 1 0 0 0 0 0 0 2 4 1 0 0 0
                  2 3 1 2 0 0 0 0 0 3 1 0 0 0 0 0 0 2 4 1 0 0 0
                  2 3 1 . . . . . . . . . . . . . . 2 4 1 0 0 0
                  2 4 2 2 0 0 0 0 0 4 2 0 0 2 0 0 0 2 4 2 0 0 2
                  2 4 2 2 0 0 0 0 0 4 2 0 0 2 0 0 0 2 4 2 0 0 2
                  2 4 2 2 0 0 0 0 0 4 2 0 0 2 0 0 0 2 4 2 0 0 2
                  2 4 2 2 0 0 0 0 0 4 2 0 0 2 0 0 0 2 4 2 0 0 2
                  2 6 3 2 1 0 0 0 0 6 3 0 0 1 1 0 0 2 6 3 0 0 1
                  2 6 3 2 1 0 0 0 0 6 3 0 0 1 1 0 0 2 6 3 0 0 1
                  2 6 3 2 1 0 0 0 0 6 3 0 0 1 1 0 0 2 6 3 0 0 1
                  2 6 3 2 1 0 0 0 0 6 3 0 0 1 1 0 0 2 6 3 0 0 1
                  2 6 3 2 1 0 0 0 0 6 3 0 0 1 1 0 0 2 6 3 0 0 1
                  2 6 3 2 1 0 0 0 0 6 3 0 0 1 1 0 0 2 6 3 0 0 1
                  2 6 3 2 1 0 0 0 0 6 3 0 0 1 1 0 0 2 6 3 0 0 1
                  2 6 3 2 1 0 0 0 0 6 3 0 0 1 1 0 0 2 6 3 0 0 1
                  2 6 3 2 1 0 0 0 0 6 3 0 0 1 1 0 0 2 6 3 0 0 1
                  2 6 3 2 1 0 0 0 0 6 3 0 0 1 1 0 0 2 6 3 0 0 1
                  2 6 3 2 1 0 0 0 0 6 3 0 0 1 1 0 0 2 6 3 0 0 1
                  2 6 3 2 1 0 0 0 0 6 3 0 0 1 1 0 0 2 6 3 0 0 1
                  2 6 3 2 1 0 0 0 0 6 3 0 0 1 1 0 0 2 6 3 0 0 1
                  2 6 3 2 1 0 0 0 0 6 3 0 0 1 1 0 0 2 6 3 0 0 1
                  2 6 3 2 1 0 0 0 0 6 3 0 0 1 1 0 0 2 6 3 0 0 1
                  2 6 3 2 1 0 0 0 0 6 3 0 0 1 1 0 0 2 6 3 0 0 1
                  2 6 3 2 1 0 0 0 0 6 3 0 0 1 1 0 0 2 6 3 0 0 1
                  2 6 3 2 1 0 0 0 0 6 3 0 0 1 1 0 0 2 6 3 0 0 1
                  2 6 3 2 1 0 0 0 0 6 3 0 0 1 1 0 0 2 6 3 0 0 1
                  2 6 3 2 1 0 0 0 0 6 3 0 0 1 1 0 0 2 6 3 0 0 1
                  2 2 0 2 0 0 0 0 0 2 0 0 0 0 0 0 0 2 2 0 0 0 0
                  2 2 0 2 0 0 0 0 0 2 0 0 0 0 0 0 0 2 2 0 0 0 0
                  2 5 3 2 0 0 0 0 0 5 3 0 0 3 0 0 0 2 5 3 0 0 3
                  2 2 0 2 0 0 0 0 0 3 1 1 0 0 0 0 0 2 4 2 2 0 0
                  2 5 3 2 0 0 0 0 0 5 3 0 0 3 0 0 0 2 5 3 0 0 3
                  2 5 3 2 0 0 0 0 0 5 3 0 0 3 0 0 0 2 5 3 0 0 3
                  2 2 0 2 0 0 0 0 0 3 1 1 0 0 0 0 0 2 4 2 2 0 0
                  2 2 0 2 0 0 0 0 0 3 1 1 0 0 0 0 0 2 4 2 2 0 0
                  2 2 0 2 0 0 0 0 0 3 1 1 0 0 0 0 0 2 4 2 2 0 0
                  2 2 0 2 0 0 0 0 0 3 1 1 0 0 0 0 0 2 4 2 2 0 0
                  2 2 0 2 0 0 0 0 0 3 1 1 0 0 0 0 0 2 4 2 2 0 0
                  2 2 0 2 0 0 0 0 0 3 1 1 0 0 0 0 0 2 4 2 2 0 0
                  2 2 0 2 0 0 0 0 0 3 1 1 0 0 0 0 0 2 4 2 2 0 0
                  2 5 3 2 0 0 0 0 0 5 3 0 0 3 0 0 0 2 5 3 0 0 3
                  2 5 3 2 0 0 0 0 0 5 3 0 0 3 0 0 0 2 5 3 0 0 3
                  2 2 0 2 0 0 0 0 0 3 1 1 0 0 0 0 0 2 4 2 2 0 0
                  2 2 0 2 0 0 0 0 0 3 1 1 0 0 0 0 0 2 4 2 2 0 0
                  2 2 0 2 0 0 0 0 0 3 1 1 0 0 0 0 0 2 4 2 2 0 0
                  2 2 0 2 0 0 0 0 0 3 1 1 0 0 0 0 0 2 4 2 2 0 0
                  2 2 0 2 0 0 0 0 0 3 1 1 0 0 0 0 0 2 4 2 2 0 0
                  2 2 0 2 0 0 0 0 0 3 1 1 0 0 0 0 0 2 4 2 2 0 0
                  2 2 0 2 0 0 0 0 0 2 0 0 0 0 0 0 0 2 2 0 0 0 0
                  2 2 0 2 0 0 0 0 0 2 0 0 0 0 0 0 0 2 2 0 0 0 0
                  2 5 3 2 0 0 0 0 0 5 3 0 1 2 0 0 0 2 5 3 0 0 3
                  1 4 3 1 0 0 0 0 0 5 4 1 0 3 0 0 0 1 5 4 1 0 3
                  2 2 0 2 0 0 0 0 0 3 1 1 0 0 0 0 0 2 3 1 1 0 0
                  1 4 3 1 0 0 0 0 0 5 4 1 0 3 0 0 0 1 5 4 1 0 3
                  2 5 3 2 0 0 0 0 0 5 3 0 1 2 0 0 0 2 5 3 0 0 3
                  2 5 3 2 0 0 0 0 0 5 3 0 1 2 0 0 0 2 5 3 0 0 3
                  1 4 3 1 0 0 0 0 0 5 4 1 0 3 0 0 0 1 5 4 1 0 3
                  1 4 3 1 0 0 0 0 0 5 4 1 0 3 0 0 0 1 5 4 1 0 3
                  2 5 3 2 0 0 0 0 0 5 3 0 1 2 0 0 0 2 5 3 0 0 3
                  2 2 0 2 0 0 0 0 0 3 1 1 0 0 0 0 0 2 3 1 1 0 0
                  1 4 3 1 0 0 0 0 0 5 4 1 0 3 0 0 0 1 5 4 1 0 3
                  2 2 0 2 0 0 0 0 0 3 1 1 0 0 0 0 0 2 3 1 1 0 0
                  2 2 0 2 0 0 0 0 0 3 1 1 0 0 0 0 0 2 3 1 1 0 0
                  2 2 0 2 0 0 0 0 0 3 1 1 0 0 0 0 0 2 3 1 1 0 0
                  1 4 3 1 0 0 0 0 0 5 4 1 0 3 0 0 0 1 5 4 1 0 3
                  2 2 0 2 0 0 0 0 0 3 1 1 0 0 0 0 0 2 3 1 1 0 0
                  1 4 3 1 0 0 0 0 0 5 4 1 0 3 0 0 0 1 5 4 1 0 3
                  1 4 3 1 0 0 0 0 0 5 4 1 0 3 0 0 0 1 5 4 1 0 3
                  2 5 3 2 0 0 0 0 0 5 3 0 1 2 0 0 0 2 5 3 0 0 3
                  1 4 3 1 0 0 0 0 0 5 4 1 0 3 0 0 0 1 5 4 1 0 3
                  end
                  label values V6958 V6958L
                  label def V6958L 1 "One major adult (Head or Wife)", modify
                  label def V6958L 2 "Two major adults (Head and Wife)", modify
                  label values V7066 V7066L
                  label def V7066L 2 "Actual number of people", modify
                  label def V7066L 3 "Actual number of people", modify
                  label def V7066L 4 "Actual number of people", modify
                  label def V7066L 5 "Actual number of people", modify
                  label def V7066L 6 "Actual number of people", modify
                  label values V7070 V7070L
                  label def V7070L 0 "None", modify
                  label def V7070L 1 "One child", modify
                  label def V7070L 2 "Two children", modify
                  label def V7070L 3 "Three children", modify
                  label values V7550 V7550L
                  label def V7550L 1 "One major adult (Head or Wife)", modify
                  label def V7550L 2 "Two major adults (Head and Wife)", modify
                  label values V7610 V7610L
                  label def V7610L 0 "Inap.: no other taxable income; Head/Wife died since last interview; Head/Wife moved out in 1981; V7609=0", modify
                  label def V7610L 1 "Actual number of exemptions", modify
                  label values V7613 V7613L
                  label def V7613L 0 "Inap.: no second highest taxable income earner; V7609=0; V7612=0", modify
                  label values V7616 V7616L
                  label def V7616L 0 "Inap.: no third highest taxable income earner; V7609=0; V7612=0; V7615=0", modify
                  label values V7619 V7619L
                  label def V7619L 0 "Inap.: no fourth taxable income earner; V7609=0; V7612=0; V7615=0; V7618=0", modify
                  label values V7622 V7622L
                  label def V7622L 0 "Inap.: no fifth highest taxable income earner; V7609=0; V7612=0; V7615=0; V7618=0; V7621=0", modify
                  label values V7657 V7657L
                  label def V7657L 1 "Actual number of people", modify
                  label def V7657L 2 "Actual number of people", modify
                  label def V7657L 3 "Actual number of people", modify
                  label def V7657L 4 "Actual number of people", modify
                  label def V7657L 5 "Actual number of people", modify
                  label def V7657L 6 "Actual number of people", modify
                  label values V7661 V7661L
                  label def V7661L 0 "None", modify
                  label def V7661L 1 "One", modify
                  label def V7661L 2 "Two", modify
                  label def V7661L 3 "Three", modify
                  label def V7661L 4 "Four", modify
                  label values V8090 V8090L
                  label def V8090L 0 "None", modify
                  label def V8090L 1 "One", modify
                  label values V8091 V8091L
                  label def V8091L 0 "None", modify
                  label def V8091L 1 "One", modify
                  label values V8092 V8092L
                  label def V8092L 0 "None", modify
                  label def V8092L 1 "One", modify
                  label def V8092L 2 "Two", modify
                  label def V8092L 3 "Three", modify
                  label values V8093 V8093L
                  label def V8093L 0 "None", modify
                  label def V8093L 1 "One", modify
                  label values V8095 V8095L
                  label def V8095L 0 "None", modify
                  label values V8097 V8097L
                  label def V8097L 0 "None", modify
                  label values V8248 V8248L
                  label def V8248L 1 "One major adult (Head or Wife)", modify
                  label def V8248L 2 "Two major adults (Head and Wife)", modify
                  label values V8351 V8351L
                  label def V8351L 1 "Actual number of people", modify
                  label def V8351L 2 "Actual number of people", modify
                  label def V8351L 3 "Actual number of people", modify
                  label def V8351L 4 "Actual number of people", modify
                  label def V8351L 5 "Actual number of people", modify
                  label def V8351L 6 "Actual number of people", modify
                  label values V8355 V8355L
                  label def V8355L 0 "None", modify
                  label def V8355L 1 "One", modify
                  label def V8355L 2 "Two", modify
                  label def V8355L 3 "Three", modify
                  label def V8355L 4 "Four", modify
                  label values V8714 V8714L
                  label def V8714L 0 "None", modify
                  label def V8714L 1 "One", modify
                  label def V8714L 2 "Two", modify
                  label values V8715 V8715L
                  label def V8715L 0 "None", modify
                  label def V8715L 2 "Two", modify
                  label values V8716 V8716L
                  label def V8716L 0 "None", modify
                  label def V8716L 1 "One", modify
                  label def V8716L 2 "Two", modify
                  label def V8716L 3 "Three", modify
                  [/CODE]

                  Comment


                  • #10
                    So you have already a combined dataset? Sorry, I have never worked with PSID.

                    I would probably approach this differently. I would assume that within each wave, variable labels are unique. If so, then i would rename variables using labels in each wave separately, appending _## to the names, where _## indicates the wave. Then I would combine (merge, I suspect) the different waves into one final dataset.

                    Comment


                    • #11
                      Thank you so much daniel klein for taking the time to read my issue and making a suggestion. I really appreciate it. I will work on it.

                      Best,

                      Comment

                      Working...
                      X