Announcement

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

  • How to make a variable from multiple categorical variables

    Good afternoon,

    The data that I am using has a unique individual identifier for each respondent, "folio." Unfortunately a mistake was made while inputting the data and in one file containing 162 food consumption questions, "alimento," each of the 162 questions have a duplicate folio when asked how often consumed weekly, "pa1," which has options 1-5. I cannot use the collapse command as I do not want the average. I cannot find a way to combine each of the 162 duplicate "folio"'s into a single person. If you have a suggestion I would greatly appreciate any help.

    Very best,
    Sue
    Last edited by Sue Green; 04 Aug 2016, 13:14. Reason: I tried to make the question clearer. I was unable to change the post title.

  • #2
    Welcome to Statalist!

    It is difficult to visualize the data you describe in words.

    Are you telling us that for each individual, there are 162 observations, each observation having three variables containing an individual identifier, a food identifier, and the consumption response? And if so, what sort of values does each take on? At a minimum, seeing the results of the describe command run on that dataset would be useful.

    Please, to increase the likelihood that Statalist readers will be able to assist you, review the Statalist FAQ linked to from the top of the page, as well as from the Advice on Posting link on the page you used to create your post. Note especially sections 9-12 on how to best pose your question.

    The more you help others understand your problem, the more likely others are to be able to help you solve your problem.

    Comment


    • #3
      Thank you William.

      For example, my file has 5,081 respondents "folio" who are asked how many days each week they eat 162 different types of foods. Each food is a category within the "alimento" variable, 162 total. How many days each week they eat it is a category within the "pa1" variable, 1=none, 2=once, 3= 2 to 3 days, 4= 4 to 6 days, and 5= 7 days.

      Instead of each alimento being linked to the same respondent, it is coded as a duplicate folio, making them not uniquely identifying. I need to combine the 162 duplicates for each "folio" as I need to merge this data set with another, using "folio" as the unique identifier. I've included below the describe command for these variables. I cannot figure out how to screen shot it as I'm remotely working on a uni server.

      obs: 823,122
      vars: 34
      size: 194,256,792

      folio long %10.0g folio
      alimento int %8.0g alimento alimento a que se refiere la pregunta
      pa1 byte %8.0g pa1 ¿cuántos dÃ*as comió o (tomó) usted?



      Thank you so much for taking the time to help me. I'm not new to Stata, although I've used it for only specific types of models, but haven't ran into this problem before.

      Warmest thanks,
      Sue

      Comment


      • #4
        Sue,

        on the surface it sounds like you need to reshape long->wide, whereas your i is folio, and your j is alimento.
        However you mention "duplicates" and "mistake". I am not sure how they complicate things.

        Best, Sergiy Radyakin

        Comment


        • #5
          Hi Sergiy Radyakin,

          Thank you for that suggestion. I tried it, and while it worked for the variables I needed, I ended up with so many extra variables as there are many different variables in this data set. I've not been able to find a way to reshape only certain variables, unfortunately, without dropping many others which isn't possible given my analysis.

          Warmest thanks,
          Sue

          Comment


          • #6
            Without knowing more about the variables in the file you need to reshape, it will be difficult to give you advice on how to proceed, other than that reshape wide is the tool you need for your problem, and if you cannot make it work for you, mostly likely you have made a mistake in giving the command, or you have problems in your data that need correcting.

            You showed us the description of your folio, alimento, and pa1 variables. The other 31 of your 34 variables should be identical for each copy of the same folio. Then something like
            Code:
            isid folio alimento
            rename pa1 pa
            reshape wide pa, i(folio) j(alimento)
            will leave your dataset in memory containing folio, pa1 through pa162 containing the value of pa for alimento 1 through alimento 162, and x1 through x31.

            If the isid command fails, it tells us you have duplicate values of alimento in some folios. You will need to investigate this and solve the duplication. If instead the reshape command tells you that one or more of the 31 additional variables are not the same for all observations within a folio, then you need to solve that problem by finding and correcting the inconsistent values.

            I again refer you to the Statalist FAQ which in section 12.1 instructs

            Say exactly what you typed and exactly what Stata typed (or did) in response. N.B. exactly! ... Never say just that something "doesn't work" or "didn't work", but explain precisely in what sense you didn't get what you wanted.
            and in section 12.3 explains using CODE delimiters to present output copied from your Results window, and in section 12.4 explains that you should not use screenshots to communicate your results.

            Comment


            • #7
              Good afternoon William,

              Thank you for your patience. I'm new to this forum, to any technical forum to be honest, and this is the first post I've written. I have read the FAQ but clearly not closely enough. I hope this hits the mark a bit closer. I did not include all variables below that I will need, but enough to give everyone an idea of what I'm dealing with. I'm not sure if this is what is useful as I'm very new to the dataex command.

              Thank you everyone for your kind help and patience,
              Sue


              Code:
              * Example generated by -dataex-. To install: ssc install dataex
              clear
              input long folio byte entidad int munici float edadanos byte(sexo pa1)
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              1060052 1  1  29.89459 1 1
              8061308 8 36 30.830936 2 5
              8061308 8 36 30.830936 2 5
              8061308 8 36 30.830936 2 3
              8061308 8 36 30.830936 2 2
              8061308 8 36 30.830936 2 2
              8061308 8 36 30.830936 2 2
              8061308 8 36 30.830936 2 3
              8061308 8 36 30.830936 2 5
              8061308 8 36 30.830936 2 3
              8061308 8 36 30.830936 2 5
              8061308 8 36 30.830936 2 2
              8061308 8 36 30.830936 2 3
              8061308 8 36 30.830936 2 2
              8061308 8 36 30.830936 2 5
              8061308 8 36 30.830936 2 5
              8061308 8 36 30.830936 2 2
              8061308 8 36 30.830936 2 2
              8061308 8 36 30.830936 2 5
              8061308 8 36 30.830936 2 2
              8061308 8 36 30.830936 2 5
              8061322 8 37  39.26078 2 5
              8061322 8 37  39.26078 2 3
              8061322 8 37  39.26078 2 3
              8061322 8 37  39.26078 2 2
              8061322 8 37  39.26078 2 2
              8061322 8 37  39.26078 2 2
              8061322 8 37  39.26078 2 2
              end
              label values sexo sexo
              label def sexo 1 "masculino", modify
              label def sexo 2 "femenino", modify
              label values pa1 pa1
              label def pa1 1 "nunca", modify
              label def pa1 2 "1", modify
              label def pa1 3 "2 - 4", modify
              label def pa1 5 "7", modify

              Comment


              • #8
                First, thank you for the use of the dataex command. That makes this sample data easier to understand, and we can copy what you posted and paste it into the do-file editor to demonstrate the reshape wide.

                However, the sample data seems to be missing alimento, which will be needed by the reshape command. Can you rerun the dataex command but include alimento?

                Comment


                • #9
                  Hello William,

                  I'm sorry about that. Here it is a second time.

                  Best,
                  Sue

                  Code:
                  * Example generated by -dataex-. To install: ssc install dataex
                  clear
                  input long folio byte entidad int(munici locali) str5 code_upm float edadanos byte sexo int alimento byte pa1
                  1060001 1 1 1 "M0101" 19.20602 1   1 1
                  1060001 1 1 1 "M0101" 19.20602 1   3 1
                  1060001 1 1 1 "M0101" 19.20602 1   4 1
                  1060001 1 1 1 "M0101" 19.20602 1   5 1
                  1060001 1 1 1 "M0101" 19.20602 1   6 1
                  1060001 1 1 1 "M0101" 19.20602 1   8 1
                  1060001 1 1 1 "M0101" 19.20602 1  10 1
                  1060001 1 1 1 "M0101" 19.20602 1  11 1
                  1060001 1 1 1 "M0101" 19.20602 1  12 1
                  1060001 1 1 1 "M0101" 19.20602 1  13 1
                  1060001 1 1 1 "M0101" 19.20602 1  14 1
                  1060001 1 1 1 "M0101" 19.20602 1  15 1
                  1060001 1 1 1 "M0101" 19.20602 1  16 1
                  1060001 1 1 1 "M0101" 19.20602 1  17 1
                  1060001 1 1 1 "M0101" 19.20602 1  18 1
                  1060001 1 1 1 "M0101" 19.20602 1  19 1
                  1060001 1 1 1 "M0101" 19.20602 1  20 1
                  1060001 1 1 1 "M0101" 19.20602 1  21 1
                  1060001 1 1 1 "M0101" 19.20602 1  22 1
                  1060001 1 1 1 "M0101" 19.20602 1  23 1
                  1060001 1 1 1 "M0101" 19.20602 1  24 1
                  1060001 1 1 1 "M0101" 19.20602 1  25 1
                  1060001 1 1 1 "M0101" 19.20602 1  26 1
                  1060001 1 1 1 "M0101" 19.20602 1  27 1
                  1060001 1 1 1 "M0101" 19.20602 1  28 1
                  1060001 1 1 1 "M0101" 19.20602 1  29 1
                  1060001 1 1 1 "M0101" 19.20602 1  30 1
                  1060001 1 1 1 "M0101" 19.20602 1  31 1
                  1060001 1 1 1 "M0101" 19.20602 1  32 1
                  1060001 1 1 1 "M0101" 19.20602 1  33 1
                  1060001 1 1 1 "M0101" 19.20602 1  34 1
                  1060001 1 1 1 "M0101" 19.20602 1  36 1
                  1060001 1 1 1 "M0101" 19.20602 1  37 1
                  1060001 1 1 1 "M0101" 19.20602 1  38 1
                  1060001 1 1 1 "M0101" 19.20602 1  39 1
                  1060001 1 1 1 "M0101" 19.20602 1  40 1
                  1060001 1 1 1 "M0101" 19.20602 1  41 1
                  1060001 1 1 1 "M0101" 19.20602 1  42 1
                  1060001 1 1 1 "M0101" 19.20602 1  45 1
                  1060001 1 1 1 "M0101" 19.20602 1  46 1
                  1060052 1 1 1 "M0102" 29.89459 1  64 1
                  1060052 1 1 1 "M0102" 29.89459 1  66 1
                  1060052 1 1 1 "M0102" 29.89459 1  67 1
                  1060052 1 1 1 "M0102" 29.89459 1  69 1
                  1060052 1 1 1 "M0102" 29.89459 1  70 1
                  1060052 1 1 1 "M0102" 29.89459 1  72 1
                  1060052 1 1 1 "M0102" 29.89459 1  73 1
                  1060052 1 1 1 "M0102" 29.89459 1  74 1
                  1060052 1 1 1 "M0102" 29.89459 1  76 1
                  1060052 1 1 1 "M0102" 29.89459 1  77 1
                  1060052 1 1 1 "M0102" 29.89459 1  78 1
                  1060052 1 1 1 "M0102" 29.89459 1  79 1
                  1060052 1 1 1 "M0102" 29.89459 1  81 1
                  1060052 1 1 1 "M0102" 29.89459 1  82 1
                  1060052 1 1 1 "M0102" 29.89459 1  84 1
                  1060052 1 1 1 "M0102" 29.89459 1  85 1
                  1060052 1 1 1 "M0102" 29.89459 1  86 1
                  1060052 1 1 1 "M0102" 29.89459 1  87 1
                  1060052 1 1 1 "M0102" 29.89459 1  88 1
                  1060052 1 1 1 "M0102" 29.89459 1  89 1
                  1060052 1 1 1 "M0102" 29.89459 1  90 1
                  1060052 1 1 1 "M0102" 29.89459 1  91 1
                  1060052 1 1 1 "M0102" 29.89459 1  92 1
                  1060052 1 1 1 "M0102" 29.89459 1  94 1
                  1060052 1 1 1 "M0102" 29.89459 1  95 1
                  1060052 1 1 1 "M0102" 29.89459 1  96 1
                  1060052 1 1 1 "M0102" 29.89459 1  97 1
                  1060052 1 1 1 "M0102" 29.89459 1  98 1
                  1060052 1 1 1 "M0102" 29.89459 1  99 1
                  1060052 1 1 1 "M0102" 29.89459 1 100 1
                  1060052 1 1 1 "M0102" 29.89459 1 103 1
                  1060052 1 1 1 "M0102" 29.89459 1 104 1
                  1060052 1 1 1 "M0102" 29.89459 1 105 1
                  1060052 1 1 1 "M0102" 29.89459 1 106 1
                  1060052 1 1 1 "M0102" 29.89459 1 107 1
                  1060052 1 1 1 "M0102" 29.89459 1 108 1
                  1060052 1 1 1 "M0102" 29.89459 1 109 1
                  1060052 1 1 1 "M0102" 29.89459 1 111 1
                  1060052 1 1 1 "M0102" 29.89459 1 113 1
                  1060052 1 1 1 "M0102" 29.89459 1 114 1
                  1060052 1 1 1 "M0102" 29.89459 1 117 1
                  1060052 1 1 1 "M0102" 29.89459 1 118 1
                  1060052 1 1 1 "M0102" 29.89459 1 119 1
                  1060052 1 1 1 "M0102" 29.89459 1 120 1
                  1060052 1 1 1 "M0102" 29.89459 1 121 1
                  1060052 1 1 1 "M0102" 29.89459 1 122 1
                  1060052 1 1 1 "M0102" 29.89459 1 123 1
                  1060052 1 1 1 "M0102" 29.89459 1 124 1
                  1060052 1 1 1 "M0102" 29.89459 1 125 1
                  1060052 1 1 1 "M0102" 29.89459 1 126 1
                  1060052 1 1 1 "M0102" 29.89459 1 127 1
                  1060052 1 1 1 "M0102" 29.89459 1 128 1
                  1060052 1 1 1 "M0102" 29.89459 1 129 1
                  1060052 1 1 1 "M0102" 29.89459 1 134 1
                  1060052 1 1 1 "M0102" 29.89459 1 136 1
                  1060052 1 1 1 "M0102" 29.89459 1 137 1
                  1060052 1 1 1 "M0102" 29.89459 1 139 1
                  1060052 1 1 1 "M0102" 29.89459 1 141 1
                  1060052 1 1 1 "M0102" 29.89459 1 145 1
                  1060052 1 1 1 "M0102" 29.89459 1 148 1
                  end
                  label values sexo sexo
                  label def sexo 1 "masculino", modify
                  label values alimento alimento
                  label def alimento 1 "leche liconsa", modify
                  label def alimento 3 "otra leche (especifique la marca):-opcion b", modify
                  label def alimento 4 "otra leche (especifique la marca):-opcion c", modify
                  label def alimento 5 "leche preparada de sabor (chocolate u otro sabor)", modify
                  label def alimento 6 "agregado a la leche:-azúcar", modify
                  label def alimento 8 "queso panela o fresco o cottage", modify
                  label def alimento 10 "yogur de vaso:-entero natural", modify
                  label def alimento 11 "yogur de vaso:-entero con frutas", modify
                  label def alimento 12 "yogur de vaso bajo en grasa o light natural o con fruta:-(vi", modify
                  label def alimento 13 "yogur para beber:-entero natural", modify
                  label def alimento 14 "yogur para beber:-entero con fruta", modify
                  label def alimento 15 "yogur para beber bajo en grasa o light natural o con fruta:-", modify
                  label def alimento 16 "danonino o similar", modify
                  label def alimento 17 "yakult o similares", modify
                  label def alimento 18 "plátano", modify
                  label def alimento 19 "plátano frito", modify
                  label def alimento 20 "jÃ*cama", modify
                  label def alimento 21 "naranja o mandarina", modify
                  label def alimento 22 "manzana o pera", modify
                  label def alimento 23 "melón o sandÃ*a", modify
                  label def alimento 24 "guayaba", modify
                  label def alimento 25 "mango", modify
                  label def alimento 26 "papaya", modify
                  label def alimento 27 "piña", modify
                  label def alimento 28 "toronja", modify
                  label def alimento 29 "fresa", modify
                  label def alimento 30 "uvas", modify
                  label def alimento 31 "durazno/melocotón", modify
                  label def alimento 32 "frutas en almÃ*bar", modify
                  label def alimento 33 "frutas cristalizadas o secas", modify
                  label def alimento 34 "tortitas de verduras capeadas", modify
                  label def alimento 36 "hojas verdes (acelgas, espinacas, quelites)", modify
                  label def alimento 37 "chayote", modify
                  label def alimento 38 "zanahoria", modify
                  label def alimento 39 "calabacita", modify
                  label def alimento 40 "brócoli o coliflor", modify
                  label def alimento 41 "col", modify
                  label def alimento 42 "ejotes", modify
                  label def alimento 45 "nopales", modify
                  label def alimento 46 "pepino", modify
                  label def alimento 64 "huevo a)", modify
                  label def alimento 66 "pescado fresco", modify
                  label def alimento 67 "pescado seco (charalitos, bacalao)", modify
                  label def alimento 69 "algún marisco (camarón, ostiones, etc.)", modify
                  label def alimento 70 "frijoles preparados en casa:-de la olla", modify
                  label def alimento 72 "frijoles envasados o de lata:-de la olla", modify
                  label def alimento 73 "frijoles envasados o de lata:-refritos", modify
                  label def alimento 74 "lenteja, garbanzo, haba amarilla o alubia", modify
                  label def alimento 76 "pan blanco", modify
                  label def alimento 77 "pan integral", modify
                  label def alimento 78 "pan dulce (excepto donas y churros)", modify
                  label def alimento 79 "donas y churros de panaderÃ*a", modify
                  label def alimento 81 "papas a)", modify
                  label def alimento 82 "papas b)", modify
                  label def alimento 84 "cereal de caja:-light/cuidado de la figura (special k)", modify
                  label def alimento 85 "cereal de caja:-hojuela endulzada (zucaritas)", modify
                  label def alimento 86 "cereal de caja:-básico (corn flakes, arroz inflado sin sabor", modify
                  label def alimento 87 "cereal de caja:-variedades(apple jacks, honey smacks, corn p", modify
                  label def alimento 88 "cereal de caja:-sabor a frutas (foot loops,)", modify
                  label def alimento 89 "cereal de caja:-fibra (all bran)", modify
                  label def alimento 90 "cereal de caja:-especialidades (crusli)", modify
                  label def alimento 91 "cereal de caja:-multi ingredientes (extra)", modify
                  label def alimento 92 "antojitos con vegetales (no tacos):-sin freÃ*r", modify
                  label def alimento 94 "antojitos con res, cerdo pollo, vÃ*sceras, etc (sin freÃ*r) co", modify
                  label def alimento 95 "antojitos con res, cerdo pollo, vÃ*sceras, etc (fritos) como", modify
                  label def alimento 96 "pozole (todos tipos)", modify
                  label def alimento 97 "tamal  (todos tipos)", modify
                  label def alimento 98 "atole de maÃ*z:-atole con agua", modify
                  label def alimento 99 "atole de maÃ*z:-atole con leche (aparte de la reportada en p.", modify
                  label def alimento 100 "refresco normal", modify
                  label def alimento 103 "café:-azúcar agregada al café", modify
                  label def alimento 104 "café:-leche agregada al café (aparte de la reportada en p. l", modify
                  label def alimento 105 "café:-sustituto de crema agregada al café", modify
                  label def alimento 106 "té o infusión:-té sin azúcar", modify
                  label def alimento 107 "té o infusión:-azúcar agregada al té", modify
                  label def alimento 108 "jugos naturales sin azúcar", modify
                  label def alimento 109 "jugos naturales con azúcar", modify
                  label def alimento 111 "aguas de fruta natural sin azúcar", modify
                  label def alimento 113 "bebidas o aguas de sabor industrializadas con azúcar (frutsi", modify
                  label def alimento 114 "néctares de frutas o pulpa de frutas industrializados con az", modify
                  label def alimento 117 "chocolate", modify
                  label def alimento 118 "dulce (caramelos, paletas)", modify
                  label def alimento 119 "dulces enchilados (miguelitos, tamarindos)", modify
                  label def alimento 120 "frituras (todos tipos, incluyendo cacahuates japoneses)", modify
                  label def alimento 121 "paletas y dulces de malvavisco (paleta payaso, bubulubu)", modify
                  label def alimento 122 "gelatina, flan", modify
                  label def alimento 123 "pastel o pay", modify
                  label def alimento 124 "helado, nieves y paletas de agua", modify
                  label def alimento 125 "helado y paletas de leche", modify
                  label def alimento 126 "cacahuates, habas o pepitas", modify
                  label def alimento 127 "palomitas de maÃ*z (microondas o cine) -todos tipos, excepto", modify
                  label def alimento 128 "pastelillos y donas industrializadas", modify
                  label def alimento 129 "galletas dulces (todos tipos)", modify
                  label def alimento 134 "sopa de pasta b)", modify
                  label def alimento 136 "sopas instantáneas", modify
                  label def alimento 137 "limón por ejemplo en ensaladas, caldos, o carnes", modify
                  label def alimento 139 "chiles frescos por ejemplo en salsas, tacos, guisados (molid", modify
                  label def alimento 141 "chile seco por ejemplo en salsas, tacos, guisados (molido  o", modify
                  label def alimento 145 "mantequilla", modify
                  label def alimento 148 "manteca vegetal", modify
                  label values pa1 pa1
                  label def pa1 1 "nunca", modify

                  Comment


                  • #10
                    William,

                    Would it be helpful to have this for the dataset I'll be merging this with?

                    Sue

                    Comment


                    • #11
                      The code you suggested gave me the following results.

                      Code:
                      . isid folio alimento
                      
                      . 
                      . rename pa1 pa
                      
                      . 
                      . reshape wide pa, i(folio) j(alimento)
                      (note: j = 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
                      >  44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 8
                      > 6 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
                      >  122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
                      >  154 155 156 157 158 159 160 161 162)
                      
                      Data                               long   ->   wide
                      -----------------------------------------------------------------------------
                      Number of obs.                   466560   ->    2880
                      Number of variables                   9   ->     169
                      j variable (162 values)        alimento   ->   (dropped)
                      xij variables:
                                                           pa   ->   pa1 pa2 ... pa162
                      -----------------------------------------------------------------------------

                      But when I merge this data with my other data set instead of having 2,880 pa1, pa2, paX variables, I have 195,458 values for each.

                      Code:
                      * Example generated by -dataex-. To install: ssc install dataex
                      clear
                      input byte pa1
                      1
                      1
                      1
                      1
                      1
                      1
                      1
                      1
                      2
                      1
                      1
                      1
                      1
                      1
                      1
                      1
                      1
                      5
                      1
                      1
                      1
                      3
                      1
                      1
                      1
                      5
                      1
                      1
                      1
                      1
                      1
                      1
                      1
                      1
                      1
                      1
                      1
                      1
                      5
                      1
                      1
                      1
                      1
                      3
                      1
                      1
                      1
                      1
                      1
                      1
                      1
                      1
                      3
                      1
                      1
                      1
                      3
                      1
                      1
                      1
                      1
                      1
                      1
                      1
                      1
                      1
                      1
                      1
                      1
                      1
                      1
                      1
                      1
                      5
                      1
                      1
                      5
                      1
                      1
                      2
                      1
                      3
                      1
                      1
                      3
                      1
                      1
                      1
                      1
                      1
                      1
                      3
                      1
                      3
                      1
                      1
                      1
                      1
                      1
                      1
                      end
                      label values pa1 pa1
                      label def pa1 1 "nunca", modify
                      label def pa1 2 "1", modify
                      label def pa1 3 "2 - 4", modify
                      label def pa1 5 "7", modify

                      Comment


                      • #12
                        Dear all,

                        Thank you so much for your help in this matter. Your suggestions were wonderful and I was able to take care of this problem. Many thanks to everyone.

                        Very best,
                        Sue

                        Comment

                        Working...
                        X