Announcement

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

  • merging 2 same answers

    hi, urgently need help to clean my data for my thesis.

    Let say we have a data

    household plot 1 plot 2 plot 3
    1 none herbicides weedicides
    2 weedicide fertilizer herbicide
    3 Fertilizer weedicide herbicides
    4 herbicides weedicide none

    Am only interested in the variables fertilizer. How can i combine this data into a single data such that i can differentiate households who used fertilizers and those who did not. Thanks


  • #2
    This can’t be your actual data since “Plot 1” is not a legal variable name. I’m also not sure if your data has strings or just labeled values.

    Please post a sample of your data using the -dataex- command. See 12.2 of the FAQ: https://www.statalist.org/forums/help#stata
    Stata/MP 14.1 (64-bit x86-64)
    Revision 19 May 2016
    Win 8.1

    Comment


    • #3
      input byte(s4avi_a162 s4avi_a163 s4avi_a170 s4avi_a171 s4avi_a178 s4avi_a179 s4avi_a186 s4avi_a187 s4avi_a194 s4avi_a195) long hhno
      1 3 1 2 . . . . . . 101005013
      1 3 1 2 . . . . . . 101005013
      1 3 1 2 . . . . . . 101005033
      1 3 1 2 . . . . . . 101005033
      1 3 1 2 . . . . . . 101005033
      1 3 . . . . . . . . 101005036
      1 3 . . . . . . . . 101005036
      1 3 . . . . . . . . 101005036
      1 4 . . . . . . . . 101006015
      1 4 . . . . . . . . 101006023
      1 2 . . . . . . . . 101007011
      1 2 1 4 1 5 1 . . . 101025002
      2 . 2 . 2 . 2 . . . 101025002
      1 4 1 4 . . . . . . 101025003
      1 4 1 2 1 3 2 . . . 101025006
      1 4 1 2 2 . 1 3 . . 101025006
      1 4 1 4 1 2 1 5 1 3 101025012
      1 4 1 3 1 2 1 5 . . 101025013
      1 4 1 3 1 2 1 5 . . 101025013
      1 4 1 4 . . . . . . 101025033
      1 4 1 4 . . . . . . 101025033
      2 . 2 . 2 . 2 . 2 . 101025037
      1 4 1 2 1 3 1 5 1 5 101025037
      1 3 1 4 1 4 1 2 1 5 101025043
      2 . 2 . 2 . 2 . . . 101025043
      1 3 1 4 1 4 . . . . 101025044
      1 4 1 4 1 2 . . . . 101025050
      1 4 1 2 1 2 . . . . 101025051
      . . . . . . . . . . 101025054
      1 4 1 4 1 4 1 5 . . 101025054
      1 4 1 4 . . . . . . 101025097
      1 4 1 3 1 4 . . . . 101025100
      1 4 1 3 1 4 . . . . 101025100
      1 4 1 2 1 2 . . . . 101025101
      . 4 . . . . . . . . 101026004
      1 5 1 4 . . . . . . 101026006
      . . . . . . . . . . 101026010
      1 2 1 4 . . . . . . 101026010
      Last edited by Baffour Duah; 28 Jul 2018, 16:20. Reason: Am only interested in the fertilizer (2) and want to know those who used fertilizer or not

      Comment


      • #4
        If you would like assistance:
        1) please follow the -dataex- onscreen instructions exactly.The part of the output that has CODE is important. It lets us know that if there are labels or not or other formatting info, and formats the code properly in the post
        2) if your data is unlabeled, please tell us the labels (I can't possibly guess what the code is for fertilizer).
        3) please tell us what the variables mean. What is the variable corresponding to plot 1 and the other variables you mention in your post?
        Stata/MP 14.1 (64-bit x86-64)
        Revision 19 May 2016
        Win 8.1

        Comment


        • #5
          . dataex

          ----------------------- copy starting from the next line -----------------------
          Code:
          * Example generated by -dataex-. To install: ssc install dataex
          clear
          input byte(s4avi_a162 s4avi_a163 s4avi_a170 s4avi_a171 s4avi_a178 s4avi_a179 s4avi_a186 s4avi_a187 s4avi_a194 s4avi_a195) long hhno
          1 3 1 2 . . . . . . 101005013
          1 3 1 2 . . . . . . 101005013
          1 3 1 2 . . . . . . 101005033
          1 3 1 2 . . . . . . 101005033
          1 3 1 2 . . . . . . 101005033
          1 3 . . . . . . . . 101005036
          1 3 . . . . . . . . 101005036
          1 3 . . . . . . . . 101005036
          1 4 . . . . . . . . 101006015
          1 4 . . . . . . . . 101006023
          1 2 . . . . . . . . 101007011
          1 2 1 4 1 5 1 . . . 101025002
          2 . 2 . 2 . 2 . . . 101025002
          1 4 1 4 . . . . . . 101025003
          1 4 1 2 1 3 2 . . . 101025006
          1 4 1 2 2 . 1 3 . . 101025006
          1 4 1 4 1 2 1 5 1 3 101025012
          1 4 1 3 1 2 1 5 . . 101025013
          1 4 1 3 1 2 1 5 . . 101025013
          1 4 1 4 . . . . . . 101025033
          1 4 1 4 . . . . . . 101025033
          2 . 2 . 2 . 2 . 2 . 101025037
          1 4 1 2 1 3 1 5 1 5 101025037
          1 3 1 4 1 4 1 2 1 5 101025043
          2 . 2 . 2 . 2 . . . 101025043
          1 3 1 4 1 4 . . . . 101025044
          1 4 1 4 1 2 . . . . 101025050
          1 4 1 2 1 2 . . . . 101025051
          . . . . . . . . . . 101025054
          1 4 1 4 1 4 1 5 . . 101025054
          1 4 1 4 . . . . . . 101025097
          1 4 1 3 1 4 . . . . 101025100
          1 4 1 3 1 4 . . . . 101025100
          1 4 1 2 1 2 . . . . 101025101
          . 4 . . . . . . . . 101026004
          1 5 1 4 . . . . . . 101026006
          . . . . . . . . . . 101026010
          1 2 1 4 . . . . . . 101026010
          1 5 1 4 . . . . . . 101026017
          1 4 1 4 . . . . . . 101026019
          . . . . . . . . . . 101026023
          1 4 1 4 1 2 . . . . 101026023
          1 2 1 4 . . . . . . 101026024
          1 2 1 4 . . . . . . 101026024
          1 4 1 2 . . . . . . 101026026
          1 2 1 4 1 4 . . . . 101026029
          . . . . . . . . . . 101026030
          1 4 1 4 . . . . . . 101026030
          1 2 1 4 . . . . . . 101026040
          1 2 1 4 . . . . . . 101026040
          1 4 1 5 . . . . . . 101026042
          1 . 1 5 . . . . . . 101026042
          . . . . . . . . . . 101026042
          1 4 1 2 . . . . . . 101026043
          1 4 1 2 . . . . . . 101026043
          . . . . . . . . . . 101028008
          . . . . . . . . . . 101028008
          . . . . . . . . . . 101028008
          1 3 . . . . . . . . 101028008
          1 4 . . . . . . . . 101028032
          . . . . . . . . . . 101028032
          2 . 1 4 . . . . . . 101028035
          1 2 1 4 . . . . . . 101028035
          2 . 2 . . . . . . . 101028035
          1 4 1 4 . . . . . . 101028041
          1 4 1 4 . . . . . . 101028041
          1 4 1 5 . . . . . . 101001004
          1 4 1 5 . . . . . . 101001004
          1 4 1 5 . . . . . . 101001004
          1 4 1 3 . . . . . . 101001015
          2 . 2 . . . . . . . 101001015
          1 4 1 3 . . . . . . 101001015
          1 3 . . . . . . . . 101001023
          1 4 . . . . . . . . 101001024
          . . . . . . . . . . 101001024
          1 4 . . . . . . . . 101001024
          1 4 . . . . . . . . 101001029
          1 2 1 2 1 4 . . . . 101001034
          2 . . . . . . . . . 101013006
          1 3 . . . . . . . . 101013006
          1 3 . . . . . . . . 101013008
          2 . . . . . . . . . 101013008
          1 . . . . . . . . . 101013008
          1 3 . . . . . . . . 101013030
          2 . . . . . . . . . 101013030
          1 2 . . . . . . . . 101013032
          2 . 1 3 . . . . . . 101013067
          1 2 2 . . . . . . . 101013067
          2 . 1 3 . . . . . . 101013067
          2 . 1 3 . . . . . . 101013067
          1 4 1 2 2 . . . . . 101013095
          2 . 2 . 1 3 1 3 . . 101013095
          1 4 . . . . . . . . 101013103
          2 . . . . . . . . . 101013103
          1 4 . . . . . . . . 101013103
          1 2 . . . . . . . . 101014022
          1 2 . . . . . . . . 101014036
          . . . . . . . . . . 101014036
          1 3 2 . 2 . 2 . . . 101014041
          1 3 1 2 1 4 1 2 . . 101014041
          end
          label values s4avi_a162 s4avi_a162
          label def s4avi_a162 1 "Yes", modify
          label def s4avi_a162 2 "No", modify
          label values s4avi_a163 s4avi_a163
          label def s4avi_a163 2 "Fertilizer (inorganic)", modify
          label def s4avi_a163 3 "Herbicide", modify
          label def s4avi_a163 4 "Insecticide", modify
          label def s4avi_a163 5 "Fungicide", modify
          label values s4avi_a170 s4avi_a170
          label def s4avi_a170 1 "Yes", modify
          label def s4avi_a170 2 "No", modify
          label values s4avi_a171 s4avi_a171
          label def s4avi_a171 2 "Fertilizer (inorganic)", modify
          label def s4avi_a171 3 "Herbicide", modify
          label def s4avi_a171 4 "Insecticide", modify
          label def s4avi_a171 5 "Fungicide", modify
          label values s4avi_a178 s4avi_a178
          label def s4avi_a178 1 "Yes", modify
          label def s4avi_a178 2 "No", modify
          label values s4avi_a179 s4avi_a179
          label def s4avi_a179 2 "Fertilizer (inorganic)", modify
          label def s4avi_a179 3 "Herbicide", modify
          label def s4avi_a179 4 "Insecticide", modify
          label def s4avi_a179 5 "Fungicide", modify
          label values s4avi_a186 s4avi_a186
          label def s4avi_a186 1 "Yes", modify
          label def s4avi_a186 2 "No", modify
          label values s4avi_a187 s4avi_a187
          label def s4avi_a187 2 "Fertilizer (inorganic)", modify
          label def s4avi_a187 3 "Herbicide", modify
          label def s4avi_a187 5 "Fungicide", modify
          label values s4avi_a194 s4avi_a194
          label def s4avi_a194 1 "Yes", modify
          label def s4avi_a194 2 "No", modify
          label values s4avi_a195 s4avi_a195
          label def s4avi_a195 3 "Herbicide", modify
          label def s4avi_a195 5 "Fungicide", modify
          ------------------ copy up to and including the previous line ------------------

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


          Labels
          Fertilizer (organic) = 1
          Fertilizer (inorganic) =2
          Herbicide = 3
          Insecticide =4
          Fungicide =5

          s4avi_a163= plot 1
          s4avi_a162= plot 2
          s4avi_a171= plot 3
          s4avi_a179= plot 4
          s4avi_a187= plot 5
          s4avi_a194= plot 6
          s4avi_a195= plot 7
          hhno= household number
          s4avi_a1620= question about whether the farmer has used any form of chemical on his or her farm.

          Only interested in fertilizer (both org and inorg)

          Hope this works. thanks




          Comment


          • #6
            The variable names and descriptions do not seem to match the labels. Here is a suggested way to go, but I only included 5 variables that had the labels that match your description (several of the variables you said describe the plot are just "yes/no", for example s4avi_a162, which you say describes plot 2).

            Code:
            egen used_fertilizer=anymatch(s4avi_a163 s4avi_a171 s4avi_a179 s4avi_a187 s4avi_a195), values(1,2)
            Stata/MP 14.1 (64-bit x86-64)
            Revision 19 May 2016
            Win 8.1

            Comment


            • #7
              Thanks so much

              Comment

              Working...
              X