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.
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.
Comment