Announcement

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

  • Collect layout error messages (e.g., collect dims not returning colnames among other things)

    Hello, I'm new to using the collect functionality in Stata and have been working my way through the user manual, but cannot reproduce most of the initial output with my own data. In my syntax below, sex is a binary variable and subject_age is continuous. I can get some code to work but not others even though I (think) I am following the examples exactly. I'm trying to eventually build out larger tables but wanted to get the basics down before trying that.

    Thank you!
    Emily



    . collect clear

    . sort sex

    . collect: by sex:summarize subject_age

    -------------------------------------------------------------------------------------------------------------------------------------------------------------------
    -> sex = Female

    Variable | Obs Mean Std. dev. Min Max
    -------------+---------------------------------------------------------
    subject_age | 42 17.42857 1.532459 13 19

    -------------------------------------------------------------------------------------------------------------------------------------------------------------------
    -> sex = Male

    Variable | Obs Mean Std. dev. Min Max
    -------------+---------------------------------------------------------
    subject_age | 66 16.95455 1.533541 13 19

    . collect layout (subject_age) (sex) (result[mean])
    (dimension subject_age not found)

    Collection: default
    Rows: subject_age
    Columns: sex
    Tables: result[mean]
    Table 1: 1 x 2

    -----------------
    Female Male
    -----------------
    17.42857 16.95455
    -----------------

    . collect dims

    Collection dimensions
    Collection: default
    -----------------------------------------
    Dimension No. levels
    -----------------------------------------
    Layout, style, header, label
    cmdset 2
    program_class 2
    result 8
    result_type 1
    sex 2

    Style only
    border_block 4
    cell_type 4
    -----------------------------------------




    collect clear

    . sort sex

    . collect: by sex:summarize subject_age

    -------------------------------------------------------------------------------------------------------------------------------------------------------------------
    -> sex = Female

    Variable | Obs Mean Std. dev. Min Max
    -------------+---------------------------------------------------------
    subject_age | 42 17.42857 1.532459 13 19

    -------------------------------------------------------------------------------------------------------------------------------------------------------------------
    -> sex = Male

    Variable | Obs Mean Std. dev. Min Max
    -------------+---------------------------------------------------------
    subject_age | 66 16.95455 1.533541 13 19

    . collect layout (subject_age#sex) (result)
    (dimension subject_age not found)

    Collection: default
    Rows: subject_age#sex
    Columns: result

    Your layout specification does not uniquely match any items. One or both of the dimensions cmdset and sex might help uniquely match items.


    . collect label list cmdset, all

    Collection: default
    Dimension: cmdset
    Label: Command results index
    Level labels:
    1
    2


    . collect layout (subject_age#sex) (cmdset)

    Collection: default
    Rows: subject_age#sex
    Columns: cmdset

    Your layout specification does not uniquely match any items. One or both of the dimensions result and sex might help uniquely match items.

  • #2
    There is no dimension named "subject_age". Just leave that empty.

    Code:
    collect clear
    sort sex
    collect: by sex:summarize subject_age
    collect layout () (sex) (result[mean])

    Comment


    • #3
      Thank you! I missed in the directions that the dimensions are created using the "by" command - so any variables for the interactions described in the instructions (subject_age#sex) first have to have that run. But it won't make sense to "by" a continuous variable for this purpose. I have some work to do!

      Comment


      • #4
        You have two variables in your example: age and sex. Do you have a specific table in mind? If you illustrate how you want the table to look, it may be possible to write code that replicates it.

        Comment

        Working...
        X