Announcement

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

  • Multiple choice variable

    Good day everyone,

    i am trying to make a cross tab analysis and I have a question regarding one of my variables.
    i have a multiple choice variable and would like to convert them into a likert scale format.
    Question: Which of the COVID-19 preventive measures have you followed during the pandemic?
    Answers
    1. Self-isolation
    2. Social distancing
    3. Wearing facemasks in public settings or transport
    4. Wearing gloves
    5. Use of hand sanitizers
    I would like to classify them as the following:
    1 scale: if respondents selected any one the results above
    2 scale: if respondents selected any two the results above
    3 scale: if respondents selected any three the results above
    4 scale: if respondents selected any four the results above
    5 scale: if respondents selected any five the results above
    This is what it looks like now with 17 sets of options, but will like to break it down to those 5 scales.
    Which of the COVID-19 |
    preventive measures |
    have you followed | Sex
    during the pandemic? | Female Male | Total
    ----------------------+----------------------+----------
    Self-isolation | 1 4 | 5
    | 0.58 1.99 | 1.34
    ----------------------+----------------------+----------
    Self-isolation, Socia | 2 0 | 2
    | 1.16 0.00 | 0.54
    ----------------------+----------------------+----------
    Self-isolation, Socia | 0 2 | 2
    | 0.00 1.00 | 0.54
    ----------------------+----------------------+----------
    Self-isolation, Socia | 1 0 | 1
    | 0.58 0.00 | 0.27
    ----------------------+----------------------+----------
    Self-isolation, Socia | 24 26 | 50
    | 13.95 12.94 | 13.40
    ----------------------+----------------------+----------
    Self-isolation, Socia | 1 0 | 1
    | 0.58 0.00 | 0.27
    ----------------------+----------------------+----------
    Self-isolation, Socia | 95 118 | 213
    | 55.23 58.71 | 57.10
    ----------------------+----------------------+----------
    Self-isolation, Weari | 1 0 | 1
    | 0.58 0.00 | 0.27
    ----------------------+----------------------+----------
    Social distancing | 1 1 | 2
    | 0.58 0.50 | 0.54
    ----------------------+----------------------+----------
    Social distancing, We | 2 2 | 4
    | 1.16 1.00 | 1.07
    ----------------------+----------------------+----------
    Social distancing, We | 24 17 | 41
    | 13.95 8.46 | 10.99
    ----------------------+----------------------+----------
    Social distancing, We | 15 23 | 38
    | 8.72 11.44 | 10.19
    ----------------------+----------------------+----------
    Social distancing, We | 0 1 | 1
    | 0.00 0.50 | 0.27
    ----------------------+----------------------+----------
    Use of hand sanitizer | 1 2 | 3
    | 0.58 1.00 | 0.80
    ----------------------+----------------------+----------
    Wearing facemasks in | 2 1 | 3
    | 1.16 0.50 | 0.80
    ----------------------+----------------------+----------
    Wearing facemasks in | 1 1 | 2
    | 0.58 0.50 | 0.54
    ----------------------+----------------------+----------
    Wearing facemasks in | 1 3 | 4
    | 0.58 1.49 | 1.07
    ----------------------+----------------------+----------
    Total | 172 201 | 373
    | 100.00 100.00 | 100.00

    Pearson chi2(16) = 14.7440 Pr = 0.543

    Will be grateful for the assistance
    Thank you.

  • #2
    If it is a single variable, how can respondents pick more than one option?

    We need a data example please to make clear how you are holding these data. https://www.statalist.org/forums/help#stata explains.

    Comment


    • #3
      It's a multiple choice section in my questionnaire so I have 17 sets of answers but would like to make them into a 5 scale format. its in a string format and would like to convert to a variable 5 scale format.
      example of responses from 373 students:
      WhichoftheCOVID19preventive_N
      Self-isolation, Social distancing, Wearing facemasks in public settings or transport, Wearing gloves, Use of hand sanitizers
      Social distancing, Wearing facemasks in public settings or transport, Use of hand sanitizers
      Self-isolation, Social distancing, Wearing facemasks in public settings or transport, Wearing gloves, Use of hand sanitizers
      Self-isolation, Social distancing, Wearing facemasks in public settings or transport, Wearing gloves, Use of hand sanitizers
      Social distancing, Wearing facemasks in public settings or transport, Wearing gloves, Use of hand sanitizers
      Self-isolation, Social distancing, Wearing facemasks in public settings or transport, Wearing gloves, Use of hand sanitizers

      Comment


      • #4
        * Example generated by -dataex-. To install: ssc install dataex
        clear
        input str124 WhichoftheCOVID19preventive
        "Self-isolation, Social distancing, Wearing facemasks in public settings or transport, Wearing gloves, Use of hand sanitizers"
        "Social distancing, Wearing facemasks in public settings or transport, Use of hand sanitizers"
        "Self-isolation, Social distancing, Wearing facemasks in public settings or transport, Wearing gloves, Use of hand sanitizers"
        "Self-isolation, Social distancing, Wearing facemasks in public settings or transport, Wearing gloves, Use of hand sanitizers"
        "Social distancing, Wearing facemasks in public settings or transport, Wearing gloves, Use of hand sanitizers"
        "Self-isolation, Social distancing, Wearing facemasks in public settings or transport, Wearing gloves, Use of hand sanitizers"
        "Self-isolation, Social distancing, Wearing facemasks in public settings or transport, Use of hand sanitizers"
        "Self-isolation, Social distancing, Wearing facemasks in public settings or transport, Wearing gloves, Use of hand sanitizers"
        "Social distancing, Wearing facemasks in public settings or transport, Use of hand sanitizers"
        "Self-isolation, Social distancing, Wearing facemasks in public settings or transport, Wearing gloves, Use of hand sanitizers"
        "Self-isolation, Social distancing, Wearing facemasks in public settings or transport, Wearing gloves, Use of hand sanitizers"
        "Social distancing, Wearing facemasks in public settings or transport, Wearing gloves, Use of hand sanitizers"
        "Social distancing, Wearing facemasks in public settings or transport, Wearing gloves, Use of hand sanitizers"
        "Self-isolation, Social distancing, Wearing facemasks in public settings or transport"
        "Self-isolation, Social distancing, Wearing facemasks in public settings or transport, Wearing gloves, Use of hand sanitizers"
        "Self-isolation, Social distancing, Wearing facemasks in public settings or transport, Use of hand sanitizers"
        "Social distancing, Wearing facemasks in public settings or transport, Use of hand sanitizers"
        "Self-isolation, Social distancing, Wearing facemasks in public settings or transport, Use of hand sanitizers"
        "Social distancing, Wearing facemasks in public settings or transport, Use of hand sanitizers"
        "Self-isolation, Social distancing, Wearing facemasks in public settings or transport, Wearing gloves, Use of hand sanitizers"
        "Self-isolation"
        "Wearing facemasks in public settings or transport, Use of hand sanitizers"
        "Self-isolation, Social distancing, Wearing facemasks in public settings or transport, Wearing gloves, Use of hand sanitizers"
        "Self-isolation, Social distancing, Wearing facemasks in public settings or transport, Wearing gloves, Use of hand sanitizers"
        --more--

        Comment


        • #5
          So, your answers are in a string variable separated by commas. The answer is just to count the commas and add 1. You count the commas by getting Stata to calculate the length of the string and also the length that the string would be if you omitted the commas. That small trick is written up at https://www.stata-journal.com/articl...article=dm0056

          Some resources are

          the split command

          https://www.stata-journal.com/articl...article=st0082 (but download software using ssc install mrtab)

          https://www.stata-journal.com/articl...article=pr0008

          tabm and tabsplit from ssc install tab_chi

          Code:
          clear
          input str124 WhichoftheCOVID19preventive
          "Self-isolation, Social distancing, Wearing facemasks in public settings or transport, Wearing gloves, Use of hand sanitizers"
          "Social distancing, Wearing facemasks in public settings or transport, Use of hand sanitizers"
          "Self-isolation, Social distancing, Wearing facemasks in public settings or transport, Wearing gloves, Use of hand sanitizers"
          "Self-isolation, Social distancing, Wearing facemasks in public settings or transport, Wearing gloves, Use of hand sanitizers"
          "Social distancing, Wearing facemasks in public settings or transport, Wearing gloves, Use of hand sanitizers"
          "Self-isolation, Social distancing, Wearing facemasks in public settings or transport, Wearing gloves, Use of hand sanitizers"
          "Self-isolation, Social distancing, Wearing facemasks in public settings or transport, Use of hand sanitizers"
          "Self-isolation, Social distancing, Wearing facemasks in public settings or transport, Wearing gloves, Use of hand sanitizers"
          "Social distancing, Wearing facemasks in public settings or transport, Use of hand sanitizers"
          "Self-isolation, Social distancing, Wearing facemasks in public settings or transport, Wearing gloves, Use of hand sanitizers"
          "Self-isolation, Social distancing, Wearing facemasks in public settings or transport, Wearing gloves, Use of hand sanitizers"
          "Social distancing, Wearing facemasks in public settings or transport, Wearing gloves, Use of hand sanitizers"
          "Social distancing, Wearing facemasks in public settings or transport, Wearing gloves, Use of hand sanitizers"
          "Self-isolation, Social distancing, Wearing facemasks in public settings or transport"
          "Self-isolation, Social distancing, Wearing facemasks in public settings or transport, Wearing gloves, Use of hand sanitizers"
          "Self-isolation, Social distancing, Wearing facemasks in public settings or transport, Use of hand sanitizers"
          "Social distancing, Wearing facemasks in public settings or transport, Use of hand sanitizers"
          "Self-isolation, Social distancing, Wearing facemasks in public settings or transport, Use of hand sanitizers"
          "Social distancing, Wearing facemasks in public settings or transport, Use of hand sanitizers"
          "Self-isolation, Social distancing, Wearing facemasks in public settings or transport, Wearing gloves, Use of hand sanitizers"
          "Self-isolation"
          "Wearing facemasks in public settings or transport, Use of hand sanitizers"
          "Self-isolation, Social distancing, Wearing facemasks in public settings or transport, Wearing gloves, Use of hand sanitizers"
          "Self-isolation, Social distancing, Wearing facemasks in public settings or transport, Wearing gloves, Use of hand sanitizers"
          end 
          
          gen wanted = 1 + (strlen(Which) - strlen(subinstr(Which, ",", "", .)))
          
          tab wanted 
          
              wanted |      Freq.     Percent        Cum.
          ------------+-----------------------------------
                    1 |          1        4.17        4.17
                    2 |          1        4.17        8.33
                    3 |          5       20.83       29.17
                    4 |          6       25.00       54.17
                    5 |         11       45.83      100.00
          ------------+-----------------------------------
                Total |         24      100.00
          
          tabsplit Which, parse(,) sort 
          
                      WhichoftheCOVID19preventive |      Freq.     Percent        Cum.
          ----------------------------------------+-----------------------------------
          Wearing facemasks in public settings .. |         23       23.71       23.71
                                Social distancing |         22       22.68       46.39
                           Use of hand sanitizers |         22       22.68       69.07
                                   Self-isolation |         16       16.49       85.57
                                   Wearing gloves |         14       14.43      100.00
          ----------------------------------------+-----------------------------------
                                            Total |         97      100.00

          Comment


          • #6
            Thank you for the assistance.
            I have 373 responses but can only view 100. how can i view the remaining?

            Comment


            • #7
              If you are alluding to the default limit of dataex, then see its help for the option count().

              Otherwise what limit are you referring to?

              Comment


              • #8
                Yes, i'm referring to datex limit. what are the options to view the rest (373) so I can put in your command

                Comment


                • #9
                  Yes, i'm referring to dataex limit. what are the options to view the rest (373) so I can put in your command.

                  Comment


                  • #10

                    Code:
                    help dataex
                    as already suggested.

                    Comment


                    • #11
                      Will do that...Thanks once again

                      Comment

                      Working...
                      X