【问题标题】:How can I create a higher dimensional table?如何创建更高维度的表?
【发布时间】:2017-07-06 12:38:37
【问题描述】:

我想在 Stata 14 中创建一个表格,其中性别的相对频率取决于该人是否就业:

我曾尝试使用 community-contributed 命令tabout,但我还没有找到处理此问题的具体示例。作为一种解决方法,我为“男性和就业”、“女性和就业”等人生成了一个具有级别的变量。

是否有不需要生成额外变量的解决方案?

【问题讨论】:

    标签: stata summary


    【解决方案1】:

    考虑以下使用 Stata 的 auto 玩具数据集的示例:

    sysuse auto, clear
    
    egen price2 = cut(price), group(4)
    label variable price2 "Price Category"
    label define price2 0 "Lower" 1 "Middle" 2 "Upper" 3 "Luxury"
    label values price2 price2
    
    recode rep78 (3=1) (4=2) (5=2)
    label define rep78 1 "Good" 2 "Poor"
    label values rep78 rep78
    

    community-contributed 命令tab3way 提供了创建此类交叉列表的方法:

    tab3way price2 rep78 foreign, rowpct nofreq rowtot format(%5.2f)
    
    Table entries are row percentages
    Missing categories ignored
    
    ------------------------------------------------------------
              |         Car type and Repair Record 1978         
    Price     | ------ Domestic ------    ------- Foreign ------
    Category  |   Good    Poor   TOTAL      Good    Poor   TOTAL
    ----------+-------------------------------------------------
        Lower |  53.85   46.15  100.00     25.00   75.00  100.00
       Middle |  76.92   23.08  100.00     25.00   75.00  100.00
        Upper |  45.45   54.55  100.00     14.29   85.71  100.00
       Luxury |  63.64   36.36  100.00            100.00  100.00
    ------------------------------------------------------------
    

    【讨论】:

    • Felix 感谢您的接受。还请考虑用上箭头(在复选标记上方)对我的答案进行投票。
    猜你喜欢
    • 1970-01-01
    • 2012-11-12
    • 2023-04-02
    • 1970-01-01
    • 2013-06-15
    • 1970-01-01
    • 1970-01-01
    • 2020-10-14
    • 1970-01-01
    相关资源
    最近更新 更多