Announcement

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

  • Reshape large data set

    Hi everyone, I have a large dataset 74,000 rows (customers) x 4,700 variables (supplier info) that looks roughly like below. Each row represents a unique customer, and the columns include data on customer financials and the top-10 suppliers' financials:

    Cust CustTA 2008 CustTA 2007 Supp1 Supp1TA 2008 Supp1TA 2007 Supp2 Supp2TA 2008 Supp2TA 2007 Supp3 Supp3TA 2008 Supp3TA 2007
    00001 a b 02222 c d 03333 e f 04444 g h
    00002 i j 05555 k l 04444 m n 06666 o p

    and I would like to translate it into a panel data set, where Cols 1 and 2 identify unique customer-years:

    Cust Year Cust TA Supp1 Supp1TA Supp2 Supp2TA Supp3 Supp3TA
    00001 2008 a 02222 c 03333 e 04444 g
    00001 2007 b 02222 d 03333 f 04444 h
    00002 2008 i 05555 k 04444 m 06666 o
    00002 2007 j 05555 l 04444 n 06666 p

    Is there any quick what I can do this? Any help at all would be appreciated.

    Thanks,
    Panos

  • #2
    I think you want:

    Code:
    reshape long CustTA Supp1 Supp1TA Supp2 Supp2TA Spp3 Supp3TA, i(Cust) j(year)
    Now you will probably say that with 4700 variables you can't list them all out like that. Fair enough. So you need to do some macro work to get Stata to do that for you. At least in what you've shown, there is regularity in the names: the year is always the final four characters of the variable name. So that's what you need to exploit. I will assume that all of your variables fit this rubric, except for the id variable Cust.

    Code:
    // FIRST GET ALL THE VARIABLE NAMES INTO A LOCAL MACRO
    ds Cust, not
    local stubs `r(varlist)'
    
    //  NOW PEEL OFF THE YEARS AT THE END
    forvalues i = 2000/2008 { // OR WHATEVER YOUR RANGE OF YEARS IS
        local stubs: subinstr local stubs "`i'" "", all
    }
    
    // NOW ELIMINATE DUPLICATE MENTIONS OF THE STUBS
    local stubs: list uniq stubs
    
    // PASS THE LIST OF STUBS TO -reshape-
    reshape long `stubs', i(Cust) j(year)
    You may need to modify this code to take into account irregularities in the variable names that are not apparent from what you posted, but this is the general approach.

    Comment


    • #3
      Originally posted by Clyde Schechter View Post
      I think you want:

      Code:
      reshape long CustTA Supp1 Supp1TA Supp2 Supp2TA Spp3 Supp3TA, i(Cust) j(year)
      Now you will probably say that with 4700 variables you can't list them all out like that. Fair enough. So you need to do some macro work to get Stata to do that for you. At least in what you've shown, there is regularity in the names: the year is always the final four characters of the variable name. So that's what you need to exploit. I will assume that all of your variables fit this rubric, except for the id variable Cust.

      Code:
      // FIRST GET ALL THE VARIABLE NAMES INTO A LOCAL MACRO
      ds Cust, not
      local stubs `r(varlist)'
      
      // NOW PEEL OFF THE YEARS AT THE END
      forvalues i = 2000/2008 { // OR WHATEVER YOUR RANGE OF YEARS IS
      local stubs: subinstr local stubs "`i'" "", all
      }
      
      // NOW ELIMINATE DUPLICATE MENTIONS OF THE STUBS
      local stubs: list uniq stubs
      
      // PASS THE LIST OF STUBS TO -reshape-
      reshape long `stubs', i(Cust) j(year)
      You may need to modify this code to take into account irregularities in the variable names that are not apparent from what you posted, but this is the general approach.
      Thanks for this code. But I have a peculiar case in which the last two digits of my variable name represents the year (e.g. f1467510 is the observation for the year 2010) but then I have variables like f0461010 and in this case "subinstr" deletes both occurrences of "10". Is there a way I can tell Stata to only delete "10" if its in the last two digits of the variable name only.

      Thanks

      Comment


      • #4
        Probably. But I would need to know more about the variable names involved to give specific advice. Are all the variable names exactly 7 characters long, the last two being the number of the year? Do they all start with f? What is the general pattern? (Or just list a fully representative sample of them.)

        Comment


        • #5
          Yes. They all start with f and the last two are always the year but not all years are present for some observations. All variables are 8 characters long including the f and 7 characters long excluding the f.

          f1121714 = "M.D.'s, Total Oth Prof Activity Non-Fed 2014"
          f1121713 = "M.D.'s, Total Oth Prof Activity Non-Fed 2013"
          f1121712 = "M.D.'s, Total Oth Prof Activity Non-Fed 2012"
          f1121711 = "M.D.'s, Total Oth Prof Activity Non-Fed 2011"
          f1121710 = "M.D.'s, Total Oth Prof Activity Non-Fed 2010"
          f1121708 = "M.D.'s, Total Oth Prof Activity Non-Fed 2008"
          f1121707 = "M.D.'s, Total Oth Prof Activity Non-Fed 2007"
          f1121706 = "M.D.'s, Total Oth Prof Activity Non-Fed 2006"
          f1121705 = "M.D.'s, Total Oth Prof Activity Non-Fed 2005"

          f1490515 = "Clin Nurs Specialist,Fmle w/NPI 2015"
          f1490514 = "Clin Nurs Specialist,Fmle w/NPI 2014"
          f1490513 = "Clin Nurs Specialist,Fmle w/NPI 2013"
          f1490512 = "Clin Nurs Specialist,Fmle w/NPI 2012"

          Comment


          • #6
            Originally posted by Clyde Schechter View Post
            Probably. But I would need to know more about the variable names involved to give specific advice. Are all the variable names exactly 7 characters long, the last two being the number of the year? Do they all start with f? What is the general pattern? (Or just list a fully representative sample of them.)
            They all start with f and the last two are always the year but not all years are present for some observations. All variables are 8 characters long including the f and 7 characters long excluding the f.

            f1121714 = "M.D.'s, Total Oth Prof Activity Non-Fed 2014"
            f1121713 = "M.D.'s, Total Oth Prof Activity Non-Fed 2013"
            f1121712 = "M.D.'s, Total Oth Prof Activity Non-Fed 2012"
            f1121711 = "M.D.'s, Total Oth Prof Activity Non-Fed 2011"
            f1121710 = "M.D.'s, Total Oth Prof Activity Non-Fed 2010"
            f1121708 = "M.D.'s, Total Oth Prof Activity Non-Fed 2008"
            f1121707 = "M.D.'s, Total Oth Prof Activity Non-Fed 2007"
            f1121706 = "M.D.'s, Total Oth Prof Activity Non-Fed 2006"
            f1121705 = "M.D.'s, Total Oth Prof Activity Non-Fed 2005"

            f1490515 = "Clin Nurs Specialist,Fmle w/NPI 2015"
            f1490514 = "Clin Nurs Specialist,Fmle w/NPI 2014"
            f1490513 = "Clin Nurs Specialist,Fmle w/NPI 2013"
            f1490512 = "Clin Nurs Specialist,Fmle w/NPI 2012"

            Comment


            • #7
              OK. You need some sort of id variable in your data set as well. I'll just assume it's called id. If there is no such variable, you can just -gen long id = _n- to create one.

              Code:
              // CREATE A LIST OF THE VARIABLES
              // STARTING WITH f AND 8 CHARACTERS LONG
              ds f???????
              local variables `r(varlist)'
              
              // CREATE STUBS BY STRIPPING THE TWO FINAL CHARACTERS
              local stubs
              foreach v of local `variables' {
                  local w = substr("`v'", 1, 6)
                  local stubs `stubs' `w'
              }
              
              // REMOVE DUPLICATES FROM THE LIST
              local stubs: list uniq stubs
              
              // NOW RESHAPE
              reshape long `stubs', i(id) j(year)
              Note: Not tested. Beware of typos or minor errors.

              Comment


              • #8
                Originally posted by Clyde Schechter View Post
                OK. You need some sort of id variable in your data set as well. I'll just assume it's called id. If there is no such variable, you can just -gen long id = _n- to create one.

                Code:
                // CREATE A LIST OF THE VARIABLES
                // STARTING WITH f AND 8 CHARACTERS LONG
                ds f???????
                local variables `r(varlist)'
                
                // CREATE STUBS BY STRIPPING THE TWO FINAL CHARACTERS
                local stubs
                foreach v of local `variables' {
                local w = substr("`v'", 1, 6)
                local stubs `stubs' `w'
                }
                
                // REMOVE DUPLICATES FROM THE LIST
                local stubs: list uniq stubs
                
                // NOW RESHAPE
                reshape long `stubs', i(id) j(year)
                Note: Not tested. Beware of typos or minor errors.
                Thanks a lot. This worked. I made some modifications to the code to transfer the variable labels after the reshape long but I keep getting an error "f14675 ambiguous abbreviation r(111);" using the code below. Any suggestions will be appreciated.


                Code:
                ds f???????
                local variables `r(varlist)'
                local stubs
                foreach v of local variables{
                local w = substr("`v'", 1, 6)
                local stubs `stubs' `w'
                }
                foreach s of local stubs{
                local vl`s' : variable label `s'20??
                local vl`s' : subinstr local vl`s' "20??" ""
                local vl`s' = trim("`vl`s''")
                } //error occurs right after running this//
                local stubs: list uniq stubs
                reshape long `stubs', i(id) j(year)
                foreach s of local stubs{
                label var `s' "`vl`s''"
                }
                The variables are labelled as such:

                Variable name = Variable label

                f1490515 = "Clin Nurs Specialist,Fmle w/NPI 2015"
                f1490514 = "Clin Nurs Specialist,Fmle w/NPI 2014"
                f1490513 = "Clin Nurs Specialist,Fmle w/NPI 2013"
                f1490512 = "Clin Nurs Specialist,Fmle w/NPI 2012"


                Comment


                • #9
                  The entire "paragraph" of code
                  Code:
                  foreach s of local stubs{
                  local vl`s' : variable label `s'20??
                  local vl`s' : subinstr local vl`s' "20??" ""
                  local vl`s' = trim("`vl`s''")
                  }
                  is wrong. There is no variable `s'20?? no matter what `s' is. While in other contexts you could use `s'20?? as a wildcard expression, you can't do that in the context of this kind of macro extended function. Also, `s', being one of the stubs, is already 6 characters long. When you stick 20 after it, even if you could expand wildcards in this context, it would lead to a total of 10 characters which does not, as I understand your data, describe any actual variables.

                  So I think what you want is this:
                  Code:
                  foreach s of local stubs{
                      local vl`s' : variable label `s'20
                      local vl`s' : subinstr local vl`s' "2020" ""
                      local vl`s' = trim("`vl`s''")
                  }
                  Finally, this block of code should go after the -local stubs: list uniq stubs- command to avoid repeating these actions on the same content over and over.

                  Comment


                  • #10
                    Clyde Schechter I ran the code but now getting a new error "variable f1533420 not found r(111);". As earlier stated, the last two digits of my variables represent the years and since I am only looking at data between the years 2007 and 2015. This variable doesn't exist. The only variable in my dataset sharing the same first six characters with this non-existent variable is

                    Variable name = Variable label
                    f1533414 = High Poverty Typology Code 2014

                    I do not have all 9 years of data for all variables in my dataset. For instance, I only have one year of data (2014) for the variable above. I have posted the exact coding I used below. Is there a way I can get around this? Thanks

                    Code:
                    ds f???????
                    local variables `r(varlist)'
                    local stubs
                    foreach v of local variables{
                    local w = substr("`v'", 1, 6)
                    local stubs `stubs' `w'
                    }
                    local stubs: list uniq stubs
                    foreach s of local stubs{
                    local vl`s' : variable label `s'20
                    local vl`s' : subinstr local vl`s' "2020" ""
                    local vl`s' = trim("`vl`s''")
                    } //error occurs right after running this//
                    reshape long `stubs', i(id) j(year)
                    foreach s of local stubs{
                    label var `s' "`vl`s''"
                    }

                    Comment


                    • #11
                      OK. I misunderstood the range of your variable names. In hindsight, it really was foolish of me to think you would have data for year 2020! I'm not sure what I was thinking. Really sorry about that.

                      So what you need to do is for each stub just identify a single variable whose name matches it. Then we need to extract the year from the last two digits of that variable name and remove reference to that year (as a four digit year starting with 20) from its label. So I think this will do it:

                      Code:
                      foreach s of local stubs{
                          // PULL ONE VARIABLE MATCHING THIS STUB
                          ds `s'??
                          local examplar: word 1 of `r(varlist)'
                      
                          // EXTRACT ITS YEAR
                          local year = substr("`examplar'", 7, 2)
                      
                          // NOW MODIFY AND SAVE THAT VARIABLE'S LABEL
                          local vl`s' : variable label `exemplar'
                          local vl`s' : subinstr local vl`s' "20`year'" ""
                          local vl`s' = trim("`vl`s''")
                      }

                      Comment


                      • #12
                        Thanks so much Clyde Schechter It worked perfectly!

                        Comment


                        • #13
                          Originally posted by Clyde Schechter View Post

                          Code:
                          // FIRST GET ALL THE VARIABLE NAMES INTO A LOCAL MACRO
                          ds Cust, not
                          local stubs `r(varlist)'
                          
                          // NOW PEEL OFF THE YEARS AT THE END
                          forvalues i = 2000/2008 { // OR WHATEVER YOUR RANGE OF YEARS IS
                          local stubs: subinstr local stubs "`i'" "", all
                          }
                          
                          // NOW ELIMINATE DUPLICATE MENTIONS OF THE STUBS
                          local stubs: list uniq stubs
                          
                          // PASS THE LIST OF STUBS TO -reshape-
                          reshape long `stubs', i(Cust) j(year)
                          Hi

                          I have a dataset with 4 variables that are not time variables, and the rest start with w?_* where ? is 1/4. I am looking for a way to reshape my wide dataset to a long one, so I've tried to use the code quoted above:

                          Code:
                          pause on
                          // FIRST GET ALL THE VARIABLE NAMES INTO A LOCAL MACRO
                          ds pid csm cluster wave_died, not
                          local stubs `r(varlist)'
                          pause
                          
                          //  Take the wave numbers out of the list of stubs
                          forvalues i = 1/4 { 
                              local stubs: subinstr local stubs "`i'" "@", all
                          }
                          pause
                          
                          // NOW ELIMINATE DUPLICATE MENTIONS OF THE STUBS
                          local stubs: list uniq stubs
                          pause
                          
                          // PASS THE LIST OF STUBS TO -reshape-
                          reshape long `stubs', i(pid) j(Wave)
                          The problem I got was that some variables had numbers at the end of their names, and those numbers were replaced instead of the number at the start of the string. e.g. w1_a_brndc_@00@ . How can I get the code to replace just the first number in the string and not the last? I have tried looking at the subinstr help file, but the syntax is different ( subinstr(s1,s2,s3,n) Description: s1, where the first n occurrences in s1 of s2 have been replaced with s3). I'm not sure what the colon does in the command "local stubs: subinstr..." and what the ", all" option does.

                          I tried pausing the output to find out what the list of variables in "stubs" looked like, but I couldn't display the list.

                          Comment


                          • #14
                            If you use the -dataex- command to show an example of your data, including variables with the problematic names, then I'm sure I can help you. But I don't want to write code for imaginary data, because the chances are good that it will be incorrect as applied to the real data.

                            If you are running version 15.1 or a fully updated version 14.2, -dataex- is already part of your official Stata installation. If not, run -ssc install dataex- to get it. Either way, run -help dataex- to read the simple instructions for using it. -dataex- will save you time; it is easier and quicker than typing out tables. It includes complete information about aspects of the data that are often critical to answering your question but cannot be seen from tabular displays or screenshots. It also makes it possible for those who want to help you to create a faithful representation of your example to try out their code, which in turn makes it more likely that their answer will actually work in your data.

                            When asking for help with code, always show example data. When showing example data, always use -dataex-.

                            Comment


                            • #15
                              Clyde Schechter

                              . dataex pid wave_died cluster w1_hhid w2_hhid w3_hhid w4_hhid w1_a_popgrp w1_c_brndc_2011 w1_c_lv06cc w2_
                              > a_popgrp w2_c_brndc_2011 w3_a_popgrp w3_c_brndc_2011 w4_a_popgrp w4_c_brndc_2011

                              ----------------------- copy starting from the next line -----------------------
                              Code:
                              * Example generated by -dataex-. To install: ssc install dataex
                              clear
                              input long pid byte wave_died int cluster long(w1_hhid w2_hhid w3_hhid w4_hhid) byte w1_a_popgrp int(w1_c_brndc_2011 w1_c_lv06cc) byte w2_a_popgrp int w2_c_brndc_2011 byte w3_a_popgrp int w3_c_brndc_2011 byte w4_a_popgrp int w4_c_brndc_2011
                              301011 . 7001 103034 220050 304902 405085 . . . . . . . . .
                              301012 . 7001 103037 210778 302440 412925 4 . . 4 . 4 . 4 .
                              301013 . 7001 103037 210778 302440 412925 4 . . . . . . 4 .
                              301014 . 7001 103037 210778 302440 412925 4 . . 4 . . . 4 .
                              301015 . 7001 103050 220052 305851 414998 4 . . . . . . . .
                              301016 . 7001 103046 220051 301578 411987 . . . . . 4 . 4 .
                              301017 . 7001 103046 220051 301578 411001 . . . . . 4 . . .
                              301018 . 7001 103049 220494 308713 407658 4 . . . . . . . .
                              301019 . 7001 103049 220494 308713 407658 4 . . . . . . . .
                              301020 . 7001 103049 220494 308713 407658 4 . . . . . . . .
                              301022 . 7001 103034 220050 304902 405085 4 . . 4 . . . . .
                              301023 . 8015 107090 212791 305588 415006 4 . . . . . . . .
                              301024 . 7001 103034 220050 304902 405085 . . . . . . . . .
                              301025 . 7001 103045 210781 308048 411782 4 . . 4 . . . . .
                              301026 4 7001 103052 210782 304048 405398 4 . . 4 . 4 . . .
                              301027 . 7001 103059 210784 307030 400945 4 . . 4 . 4 . 4 .
                              301028 . 7001 103046 220051 301578 411987 . . . . . 4 . 4 .
                              301029 . 7001 103045 210781 308048 411782 4 . . . . . . . .
                              301031 . 7001 103058 210783 308285 411829 4 . . . . . . . .
                              301033 . 7001 103058 210783 308285 411829 . . . . . . . . .
                              301034 . 7001 103045 215945 308048 411782 4 . . . . . . . .
                              301035 . 7001 103045 215945 308048 411782 4 . . . . . . . .
                              301036 . 7001 103049 220494 308713 407658 4 . . . . . . . .
                              301038 . 7001 103058 210783 308285 411829 4 . . . . . . . .
                              301040 . 7001 103046 220051 301578 411001 4 . . . . 4 . 4 .
                              301041 . 7001 103058 210783 308285 411829 4 . . . . . . . .
                              301043 . 7001 103050 220052 305851 414998 4 . . . . . . . .
                              301045 . 7001 103052 210782 304048 405398 4 . . 4 . 4 . 4 .
                              301047 . 7021 103006 215947 306433 404272 4 . . 4 . . . 4 .
                              301048 . 7021 103013 210774 304485 400430 4 . . 4 . 4 . . .
                              301049 . 7021 103021 215948 308524 402884 3 . . . . . . . .
                              301050 . 7021 103025 220898 301121 414243 3 . . . . . . . .
                              301051 . 7021 103025 220899 301685 411224 3 . . . . . . 3 .
                              301052 2 7021 103009 210772      .      . 4 . . . . . . . .
                              301053 . 7021 103013 210774 307363 412343 4 . . 4 . 4 . . .
                              301054 . 7021 103006 217676 300610 406142 4 . . . . 4 . 4 .
                              301055 . 7021 103022 210775 309968 412854 4 . . . . . . . .
                              301056 . 7021 103013 210774 304485 400430 4 . . 4 . 4 . . .
                              301057 2 7021 103025 218183      .      . 3 . . . . . . . .
                              301058 . 7021 103025 218183 301685 411224 3 . . 3 . 3 . 3 .
                              301059 . 7021 103026 210776 301484 403065 1 . . 1 . . . 1 .
                              301060 . 7021 103011 210773 308158 407379 4 . . 4 . . . . .
                              301061 . 7021 103007 210771 304372 413882 . . . 2 . . . . .
                              301062 . 7021 103026 210776 301484 407305 1 . . 1 . 1 . 1 .
                              301064 . 7021 103006 215947 306433 406274 4 . . 4 . . . 4 .
                              301065 . 7021 103009 210772 303697 407757 4 . . 4 . . . 4 .
                              301066 . 7021 103009 210772 303697 407757 4 . . 4 . 4 . 4 .
                              301067 . 7046 112562 214985 301218 413834 1 . . 1 . 1 . 1 .
                              301068 . 7046 102152 215949 300365 403559 1 . . 1 . . . 1 .
                              301069 . 7021 103011 215950 308492 408660 . . . . . . . . .
                              301070 . 7046 112542 214981 300916 403882 1 . . 1 . 1 . 1 .
                              301071 . 7046 112550 215951 305552 400073 1 . . 1 . 1 . 1 .
                              301072 . 7036 102167 220900 308155 411406 1 . . . . 1 . 1 .
                              301073 . 7036 102016 210388 304038 405826 1 . . 1 . 1 . 1 .
                              301074 . 7045 112162 214827 301059 414699 1 . . 1 . 1 . 1 .
                              301075 . 7036 102166 210432 307101 412052 1 . . 1 . 1 . 1 .
                              301076 . 8021 102458 210532 302258 409868 1 . . 1 . 1 . 1 .
                              301077 . 7036 102016 210388 304038 405826 1 . . 1 . 1 . 1 .
                              301079 . 7046 102151 210421 302096 412601 1 . . 1 . . . 1 .
                              301080 . 7046 112563 214986 301446 405283 1 . . 1 . 1 . 1 .
                              301081 . 7046 112563 214986 301446 405283 1 . . 1 . 1 . 1 .
                              301082 . 7017 103073 210789 308469 407047 1 . . 1 . 1 . 1 .
                              301083 . 7017 103090 210797 300097 407576 1 . . . . . . 1 .
                              301084 . 7017 103062 210786 303867 407556 1 . . 1 . 1 . 1 .
                              301085 2 6032 103254 210866      .      . 1 . . . . . . . .
                              301086 . 7017 103062 215952 300340 406777 1 . . 1 . 1 . 1 .
                              301087 3 7017 103087 215953 308168      . 1 . . . . . . . .
                              301088 . 7017 103073 217677 300935 411208 1 . . 1 . . . 1 .
                              301090 . 7017 103088 210796 309939 400396 1 . . 1 . 1 . 1 .
                              301091 . 7017 103088 210796 309939 406194 1 . . 1 . . . 1 .
                              301092 . 7017 103073 217997 300268 414905 1 . . 1 . 1 . 1 .
                              301093 2 7017 103086 210795      .      . 1 . . . . . . . .
                              301094 4 7017 103075 210790 307271 400686 1 . . . . . . . .
                              301095 . 6032 103246 210863 307613 414555 1 . . 1 . 1 . 1 .
                              301096 . 6032 103255 210867 303369 405000 1 . . 1 . 1 . 1 .
                              301099 . 7017 103071 215954 304759 413636 1 . . . . . . . .
                              301100 . 7017 103063 215955 308355 403418 1 . . . . . . . .
                              301101 . 7030 103109 210805 300308 406051 . . . . . . . . .
                              301102 . 7025 103165 210829 305215 404968 1 . . 1 . 1 . 1 .
                              301103 . 7025 103175 210830 301901 413391 2 . . 2 . 2 . . .
                              301104 . 7025 103175 210830 301901 409036 2 . . 2 . 2 . 2 .
                              301105 . 7025 103178 210831 300553 414591 2 . . 2 . 2 . 2 .
                              301106 . 7025 103178 210831 300553 414591 2 . . 2 . 2 . 2 .
                              301107 . 7025 103156 210827 307724 408084 2 . . 2 . . . . .
                              301108 . 7025 103156 210827 307724 408084 2 . . 2 . 2 . 2 .
                              301110 . 7025 103156 210827 307724 408084 2 . . 2 . 2 . . .
                              301111 . 7036 102160 210427 304453 411559 1 . . 1 . 1 . . .
                              301112 . 7025 103263 215956 306151 403724 1 . . . . 1 . . .
                              301113 . 7030 103109 210805 305371 401100 . . . 1 . . . . .
                              301114 . 7025 103152 215957 307526 409606 2 . . . . . . . .
                              301115 . 7030 103109 210805 300308 406051 . . . 1 . 1 . 1 .
                              301117 . 6028 112076 215958 305541 411726 1 . . . . . . . .
                              301121 . 7030 103109 210805 300308 406051 . . . 1 . 1 . 1 .
                              301123 . 7036 102161 210428 305652 401306 1 . . 1 . 1 . 1 .
                              301124 . 7036 102166 210432 307101 412052 1 . . 1 . 1 . 1 .
                              301125 . 7036 102166 210432 307101 412052 1 . . 1 . 1 . 1 .
                              301126 4 7007 101659 210242 303477 408754 1 . . . . 1 . . .
                              301127 2 7007 101666 210245      .      . 1 . . . . . . . .
                              301128 . 7007 101669 210247 302731 408088 1 . . 1 . 1 . 1 .
                              301130 . 7025 103154 210826 302656 406288 2 . . 2 . 2 . 2 .
                              end
                              label values wave_died wave_died
                              label def wave_died 2 "Deceased at Wave 2", modify
                              label def wave_died 3 "Deceased at Wave 3", modify
                              label def wave_died 4 "Deceased at Wave 4", modify
                              label values cluster w3_nonrescodes
                              label values w1_a_popgrp w1_popgrp
                              label def w1_popgrp 1 "African", modify
                              label def w1_popgrp 2 "Coloured", modify
                              label def w1_popgrp 3 "Asian/Indian", modify
                              label def w1_popgrp 4 "White", modify
                              label values w1_c_brndc_2011 w1_dc_2011
                              label values w1_c_lv06cc w1_cc
                              label values w2_a_popgrp w2_popgrp
                              label def w2_popgrp 1 "African", modify
                              label def w2_popgrp 2 "Coloured", modify
                              label def w2_popgrp 3 "Asian/Indian", modify
                              label def w2_popgrp 4 "White", modify
                              label values w2_c_brndc_2011 w2_dc_2011
                              label values w3_a_popgrp w3_popgrp
                              label def w3_popgrp 1 "African", modify
                              label def w3_popgrp 2 "Coloured", modify
                              label def w3_popgrp 3 "Asian/Indian", modify
                              label def w3_popgrp 4 "White", modify
                              label values w3_c_brndc_2011 w3_dc_2011
                              label values w4_a_popgrp w4_popgrp
                              label def w4_popgrp 1 "African", modify
                              label def w4_popgrp 2 "Coloured", modify
                              label def w4_popgrp 3 "Asian/Indian", modify
                              label def w4_popgrp 4 "White", modify
                              label values w4_c_brndc_2011 w4_dc_2011
                              ------------------ copy up to and including the previous line ------------------

                              Listed 100 out of 50379 observations
                              Use the count() option to list more

                              .

                              Comment

                              Working...
                              X