Announcement

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

  • Collect: How to combine percent statistics from table with data collected from sum

    Currently I have the table below by using collect, table and appending them together:
    Code:
    collect: table (educ_4concat) (labforce sex), statistic(percent, across(labforce)) nototals style(table-1)
    
    collect: table (age_4concat) (labforce sex), statistic(percent, across(labforce)) nototals append
    
    collect: table (race_3concat) (labforce sex), statistic(percent, across(labforce)) nototals append
    
    
    collect layout (educ_4concat age_4concat race_3concat) (labforce[2]#sex)
    However, I would like to add mean of annual hours work as a new column after collecting them:

    Code:
    gen annualwork = uhrsworkt * 52
    bysort educ_4concat: summarize annualwork
    collect: bysort educ_4concat: summarize annualwork
    bysort age_4concat: summarize annualwork
    collect: bysort age_4concat: summarize annualwork
    bysort race_3concat: summarize annualwork
    collect: bysort race_3concat: summarize annualwork
    How can I use collect to add the column of mean annual hours work to the existing table?

    Thank you for your answers in advance!
    Attached Files
    Last edited by Shin Jiraphongtrakul; 05 Oct 2023, 01:41.

  • #2
    Perhaps something along the lines of this will work. First add the means to the collection, which you can subsequently add to a layout.

    Code:
    collect: table (educ_4concat) (), stat(mean annualwork) append
    collect: table (age_4concat) (), stat(mean annualwork) append
    collect: table (race3_concat) (), stat(mean annualwork) append
    
    collect layout (educ_4concat age_4concat race3_concat) (labforce[2]#sex result[mean])
    Without the data, I cannot test this for you.

    Comment


    • #3
      Thank you, sorry for the late reply. I was able to use this and get my desired result.

      Comment

      Working...
      X