Announcement

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

  • how to use table command to analyze multiple choice question?

    hi masters,


    I just meet a problem which is somewhat frustrated. The survey question always contain some multiple choice questions. Now, the user-written command called "mrtab" works well, but the result is very hard to export to excel, comparing with the table command.

    I want to use table command to export multiple question result, mostly the twoway-tablulations. Here is an example below:


    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input double id long(C8__1__1 C8__1__2 C8__1__3 C8__1__4 C8__1__5 C8__1__6 C8__1__7 age)
    5981 1 0 0 0 1 1 0 2
    2069 1 0 0 0 0 0 0 4
    3988 1 0 0 0 0 0 0 2
    3766 1 0 0 1 0 0 0 3
     997 1 0 0 0 0 0 0 2
    3869 0 1 1 0 0 0 0 2
    7296 1 0 0 0 0 0 0 2
    8019 1 0 0 0 0 0 0 5
    5503 1 0 0 0 0 0 0 2
    7734 1 1 0 0 0 0 0 3
     300 1 0 1 0 1 1 0 4
    7132 1 0 0 0 0 0 0 3
    2393 1 0 0 0 1 1 0 2
    3703 1 0 0 0 0 0 0 3
    3510 1 1 0 0 0 0 0 2
    8531 1 0 0 0 0 0 0 3
    8551 1 0 0 0 0 1 0 3
    3536 1 1 1 1 0 0 0 2
    4255 1 0 0 0 0 0 0 3
    3786 1 1 1 0 0 0 0 2
    2782 1 1 1 0 0 0 0 3
    3052 1 0 1 1 0 0 0 3
    2519 0 0 1 0 0 0 0 2
     230 0 0 1 0 0 0 0 1
    4195 1 1 1 0 0 0 0 1
    7415 1 0 0 0 0 0 0 2
    8522 1 0 0 0 0 0 0 3
    8503 1 0 1 0 1 0 0 3
    4269 1 0 0 0 0 0 0 3
    4927 1 0 0 0 0 0 0 3
     969 1 0 0 0 1 0 0 2
    9067 1 0 0 0 0 0 0 3
    3670 1 0 0 0 0 0 0 3
    5774 1 0 0 0 1 0 0 2
    7088 1 1 1 0 0 0 0 2
    2568 0 0 1 0 0 0 0 4
    8619 1 1 0 0 0 0 0 3
    9202 1 0 0 0 0 0 0 2
    9046 1 0 0 0 0 0 0 3
    6165 1 0 0 1 0 0 0 3
     322 1 0 1 0 0 0 0 1
    5889 0 0 0 0 1 0 0 3
    6483 1 0 0 0 0 0 0 3
    2212 1 1 1 1 1 0 0 3
    8798 1 0 0 0 0 0 0 3
    9021 1 0 0 0 0 0 0 3
    8923 1 1 1 1 1 1 0 2
    1063 1 0 0 0 0 0 0 2
    8242 1 0 0 0 0 0 0 2
    6315 1 0 1 0 1 0 0 3
    2985 1 0 0 0 0 0 0 1
    9127 1 0 0 0 0 0 0 4
    9035 1 0 0 0 0 0 0 3
     162 1 0 0 1 0 0 0 2
    4148 0 0 0 1 0 0 0 2
    5896 1 0 0 0 1 0 0 2
     974 1 0 0 0 0 1 0 2
    5571 1 0 0 0 0 0 0 3
    1655 1 0 0 0 0 0 0 2
    4123 1 0 0 1 0 0 0 3
     924 1 0 0 1 0 0 0 3
    8069 1 0 1 0 0 0 0 3
    8084 1 0 0 0 0 0 0 2
    4801 1 1 1 0 0 0 0 2
    7096 1 0 0 0 0 0 0 3
    7418 1 0 1 1 0 0 0 3
    7940 1 0 0 0 0 0 0 2
    9187 1 0 0 0 0 0 0 2
    5083 1 0 0 0 0 0 0 3
    2403 1 0 0 0 0 0 0 3
    3188 1 0 0 0 0 0 0 2
    2276 1 0 0 1 0 0 0 3
    8247 1 0 0 1 0 1 0 3
    3984 1 0 0 0 0 0 0 3
      31 1 0 0 1 0 0 0 2
    2806 1 1 0 0 0 0 0 2
    6317 1 0 1 0 1 0 0 2
    5204 1 0 1 1 1 1 0 3
    6226 1 0 0 0 0 0 0 2
    8758 1 0 0 1 0 1 0 4
     952 1 0 0 1 0 0 0 4
    4634 1 0 0 1 0 1 0 2
    8124 1 1 0 0 0 0 0 3
    9063 1 0 0 0 0 1 0 3
      27 1 1 1 1 0 0 0 2
     118 1 0 1 1 0 0 0 2
    3754 1 0 1 0 0 0 0 3
    8844 1 0 0 0 0 0 0 3
    3909 1 0 0 1 0 0 0 2
    5281 1 0 0 0 0 0 0 4
    6627 1 0 0 0 0 0 0 2
    6817 1 1 0 0 0 0 0 3
    end
    label values C8__1__1 C8__1__1
    label values C8__1__2 C8__1__2
    label values C8__1__3 C8__1__3
    label values C8__1__4 C8__1__4
    label values C8__1__5 C8__1__5
    label values C8__1__6 C8__1__6
    label values C8__1__7 C8__1__7
    label values age age
    label def age 1 "<24years", modify
    label def age 2 "25-34years", modify
    label def age 3 "35-44years", modify
    label def age 4 "45-55years", modify
    label def age 5 ">55years", modify
    
    * ssc install mrtab // install mrtab if needed
    
    mrtab C8__1__1-C8__1__7, by(age) rcol nofreq  
    _mrsvmat, stat(rcol) rtotal clear nopercent         // the result is what I want, but how to do this by table command?
    
    * ideally, I want a table like this:
    table ()(age), stat(mean C8__1__1-C8__1__7) stat(n age) listwise
    
    * but the value of each cell is not correct because I want the percentage is a relative percentage

    The most important reason that I do not want to use mrtab is that, it can not use collect commands to manage the tables and combined with other table commands to export to excel.

    Anyone has idea to use table command to replicate the result as mrtab?



    Last edited by BICHENG NIU; 24 Nov 2021, 02:14.

  • #2
    up

    Comment


    • #3
      any people has an idea?

      Comment


      • #4
        up

        Comment


        • #5
          Bicheng, please stop bumping your question. Once or twice is ok, but now it is excessive. You have received no response by now which should tell you that either your question was unclear (I don't think it was) or that people have not figured out how to meet your wants with the table command. Table is relatively new command and many are not fully fluent with it.

          Have you tried to do this yourself? Have you mad any progress?

          Comment


          • #6
            Originally posted by Leonardo Guizzetti View Post
            Bicheng, please stop bumping your question. Once or twice is ok, but now it is excessive. You have received no response by now which should tell you that either your question was unclear (I don't think it was) or that people have not figured out how to meet your wants with the table command. Table is relatively new command and many are not fully fluent with it.

            Have you tried to do this yourself? Have you mad any progress?
            Sorry, I'm too selfish to post the question again and again. Actually I‘ve been working on this problem 2 months, the programming skill requirement may be too strict for me to tackle it.

            Comment


            • #7
              Originally posted by BICHENG NIU View Post

              Sorry, I'm too selfish to post the question again and again. Actually I‘ve been working on this problem 2 months, the programming skill requirement may be too strict for me to tackle it.
              It's okay. It's easy to get stuck on a problem in search of a solution. I think 2 months is a very long time to make no observable progress. You should consider trying to recreate the statistics you want using other methods, even if it's not as slick as a one-line command. Perhaps later, when you have gained some more skill with Stata and programming, you can revisit the problem.

              Comment

              Working...
              X