Announcement

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

  • labeling value multi_responses variable

    Hi All ,

    I am now labeling the variables : there is some issues for multivalues
    I have data set like this variable : available water sources ? the options are as follow , allow multiple selection so responses in the data set are likes 1 3 ...4 5 .....1 2 3...... 178 , etc because they are selected by multiple options so how can label value those kinds of multiple response . please help .
    1 Surface water (river, pond etc)
    2 Rainwater
    3 Borehole
    4 Unprotected spring or well
    5 Protected spring or well
    6 Tanker truck or cart
    7 Public tap
    8 Piped into house
    9 Bottled

  • #2
    Is this variable a string data type, say, with multiple selections separated with a space? For example, did you mean to write "1 7 8" and not "178", or is it that there may be (is allowed) to have multiple choices present in the variable as run-together and not always space-separated?

    Comment


    • #3
      Thein, if you your variable represents multi response question, it means respondents can choose more than one or all of the categories listed in your question.
      then while entering your data in to Stata you must have as many variables as number of categories of your multi-response question (In your data set it must be 9 variables)
      then define a new value label which includes all of them (lab def LABEL 1"Surface Water" 2"Rain Water" ... 9"Bottled"), then assign this value label to all of your variables.
      Last edited by Fahim Ahmad; 27 Apr 2017, 00:35.

      Comment


      • #4
        Hi Fahim ,
        Thanks for your explanation ,
        You mean firstly doing (lab def water_source 1 " " 2" " ....9" ) and then (lab val q_31 water_source ) . I already did like that but this is not work .These are all strings and one column have more than one responses (multiple response) , do I need any preparation before this step ? .Please see like this my data set :
        q_31
        2 3 7
        3 7 8
        2
        8
        2 9
        3
        1 5
        4 7

        Comment


        • #5
          You can't label string variables in Stata. For discussions of this problem of multiple responses to survey questions see e.g. http://www.stata-journal.com/sjpdf.html?articlenum=pr0008 and http://www.stata-journal.com/sjpdf.h...iclenum=st0082

          Your existing variable can be used: search this forum for mentions of tabsplit from tab_chi (SSC) but I agree with Fahim that also using separate indicator variables would be a good idea.

          Code:
          forval j = 1/9 { 
                 gen q_31_`j'  = strpos(" " + q_31 + " ", " `j' ") > 0 
          }
          The leading and trailing spaces are needed for more challenging examples of this kind. In your case, this works


          Code:
          clear 
          input str5 q_31 
          "2 3 7"
          "3 7 8"
          "2"
          "8"
          "2 9"
          "3"
          "1 5"
          "4 7"
          end 
          
          forval j = 1/9 { 
              gen q_31_`j' = strpos(q_31, "`j'") > 0 
          } 
          
          list
          Please supply data examples as requested in FAQ Advice #12.

          Comment


          • #6
            Hi ,
            I am a new leaner so I have so many things to know about stata , the question : q_31 .available water sources ?
            The options are :
            1 Surface water (river, pond etc)
            2 Rainwater
            3 Borehole
            4 Unprotected spring or well
            5 Protected spring or well
            6 Tanker truck or cart
            7 Public tap
            8 Piped into house
            9 Bottled
            Actually in my data set presents like this
            q_31 q_31_1 q_31_2 q_31_3 q_31_4 q_31_5 q_31_6 q_31_7 q_31_8 q_31_9 q_31_10 q_31_11 q_31_12 q_31_13 q_31_88
            2 3 12 FALSE TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE FALSE FALSE
            3 7 12 FALSE FALSE TRUE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE TRUE FALSE FALSE
            2 FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
            8 FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE
            2 12 FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE FALSE FALSE
            3 88 FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE
            I would like to make label value ,

            Please help me this ...

            Comment


            • #7
              Please have a look on FAQ on how to post an example of your data-set, anyway send me your data-set through this email ([email protected]) to look on it.

              Comment


              • #8
                Originally posted by Thein Zaw View Post
                the question : q_31 .available water sources ?
                The options are : . . .

                I would like to make label value
                If the options were as you show (only 1 through 9), then how did you get values of 10, 11, 12, 13 and 88? (And 178?) What are the labels for those values?

                Comment


                • #9
                  Sorry , I make missing copy ... here is correct options :q_31_What different kinds of disasters and emergencies can you think of?
                  The options ;
                  1 Landslides
                  2 Flooding
                  3 Typhoons
                  4 Drought
                  5 Storm surge
                  6 Volcanic eruptions
                  7 Earthquakes
                  8 Infectious Disease Epidemic
                  9 War/violence/conflict
                  10 Displacement
                  11 Mass Exposure to Toxin/Chemical
                  12 None
                  88 Other, specify
                  In data set , present like this ;
                  _id q_31 q_31_1 q_31_2 q_31_3 q_31_4 q_31_5 q_31_6 q_31_7 q_31_8 q_31_9 q_31_10 q_31_11 q_31_12 q_31_13 q_31_88
                  6832555 2 3 12 FALSE TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE FALSE FALSE
                  6832556 3 7 12 FALSE FALSE TRUE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE TRUE FALSE FALSE
                  6832557 2 FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
                  6832559 8 FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE
                  6832560 2 12 FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE FALSE FALSE
                  6832561 3 88 FALSE FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE
                  6832562 12 88 FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE FALSE TRUE
                  6832563 13 FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE FALSE
                  6832564 13 FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE FALSE
                  6832565 13 FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE FALSE
                  6832566 13 FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE FALSE
                  6832569 2 4 FALSE TRUE FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
                  6832570 88 FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE
                  6832573 13 FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE FALSE
                  6832574 2 12 FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE FALSE FALSE
                  6832575 13 FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE FALSE
                  6832576 1 88 TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE
                  6832577 13 FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE FALSE
                  6832578 2 12 FALSE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE TRUE FALSE FALSE
                  6832579 1 2 TRUE TRUE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE FALSE
                  6832612 2 5 8 12 88 FALSE TRUE FALSE FALSE TRUE FALSE FALSE TRUE FALSE FALSE FALSE TRUE FALSE TRUE
                  How can I do label value for those kind of multiple response ?
                  Help me .

                  Comment


                  • #10
                    You might want to check again: what's 13?

                    Anyway, you'll need to say just what it is that you're after. What do you want things to look like when you're done? I doubt that you want blanks wherever there is "FALSE" and a value label for wherever there is "TRUE" . . .

                    Comment


                    • #11
                      Hi Joseph ,
                      13 Means 1 3 . Because these all data are downloaded from KoBo data collection apk . We have used KoBo application for data collection.

                      Comment


                      • #12
                        Thein Zaw, I have send you the commands in your e-mail, check your inbox.

                        Comment


                        • #13
                          Hi Thein Zaw clear input str10 q_31 "2 3 7 88" "3 7 8" "2" "8" "2 9" "3" "1 5" "4 7" end split q_31 drop q_31 destring q_31*, replace lab def LABEL 1 "Landslides" 2 "Flooding" 3 "Typhoons" 88 "Other, specif" lab val q_31* LABEL list

                          Comment


                          • #14
                            I am sorry for mistake
                            Code:
                            clear 
                            input str10 q_31 
                            "2 3 7 88"
                            "3 7 8"
                            "2"
                            "8"
                            "2 9"
                            "3"
                            "1 5"
                            "4 7"
                            end 
                            split q_31
                            drop q_31
                            destring q_31*, replace
                            lab def LABEL 1 "Landslides" 2    "Flooding" 3 "Typhoons" 88 "Other, specif"
                            lab val q_31* LABEL
                            list

                            Comment

                            Working...
                            X