Announcement

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

  • Challanging table collect

    I am using Stata 17.

    I have three variable to work with. These are the variables:

    Code:
    q1_3 q6_2_achievement_red q6_2_target_red
    Nari Moitree 54 0
    Shimantik 32 14
    PSTC 22 0
    Nari Moitree 86 214
    PSTC 60 41
    I am using this code for table generation:

    Code:
    table (q1_3),nototals stat(frequency) stat(mean q6_2_achievement_red q6_2_target_red) stat(sd q6_2_achievement_red q6_2_target_red)
    Now I need to modify my collection layout something like this. Basically I want to put mean and sd side by side.

    Frequency q6_7_achievement_Mean q6_7_achievement_sd q6_7_target_Mean q6_7_target_sd
    q1_3 Select PA NGO:
    Shimantik
    BAPSA

  • #2
    After your call to table, try
    Code:
    collect layout (q1_3) (var#result)
    This will nest the result levels within the column variables from
    which the statistics are computed.

    You could also specify var and result in your call to
    table. For example, the following will have the same effect on
    the layout as the above
    Code:
    table (q1_3) (var result), ///
        nototals ///
        stat(frequency) ///
        stat(mean q6_2_achievement_red q6_2_target_red) ///
        stat(sd q6_2_achievement_red q6_2_target_red)
    Either way, the table will look like
    Code:
    -----------------------------------------------------------------------------------
                   |  Frequency      q6_2_achievement_red          q6_2_target_red     
                   |              Mean   Standard deviation   Mean   Standard deviation
    ---------------+-------------------------------------------------------------------
    q1_3           |                                                                   
      Nari Moitree |          2     70             22.62742    107             151.3209
      PSTC         |          2     41             26.87006   20.5             28.99138
      Shimantik    |          1     32                    .     14                    .
    -----------------------------------------------------------------------------------
    If the variables q6_2_achievement_red and q6_2_target_red
    have labels, they will show up in the table's column header instead of
    their names. Also, if you feel the default result labels are too
    verbose, you can change them with collect label levels; for example
    Code:
    . collect label levels var ///
    >         q6_2_achievement_red "Achievement" ///
    >         q6_2_target_red "Target" ///
    >         , modify
    
    . collect label levels result ///
    >         sd "SD" ///
    >         frequency "Freq." ///
    >         , modify
    
    . collect preview
    
    -----------------------------------------------------------
                   |  Freq.     Achievement          Target
                   |          Mean         SD   Mean         SD
    ---------------+-------------------------------------------
    q1_3           |
      Nari Moitree |      2     70   22.62742    107   151.3209
      PSTC         |      2     41   26.87006   20.5   28.99138
      Shimantik    |      1     32          .     14          .
    -----------------------------------------------------------

    Comment


    • #3
      Thanks a lot!!

      Comment

      Working...
      X