【问题标题】:Formatting a Stata table like a table in SAS像 SAS 中的表一样格式化 Stata 表
【发布时间】:2021-01-19 01:43:32
【问题描述】:

我在 Stata 中有一个 3 路表,如下所示:

我想将此三向交叉表格式化为 SAS 中的表格,如下所示:

表中的实际输出并不重要,我只想知道如何更改 Stata 表的格式。任何帮助表示赞赏!

【问题讨论】:

标签: sas stata


【解决方案1】:

Stata Journal 中的groups 命令将帮助您完成大部分工作。这个可重现的例子并没有穷尽可能性。

. webuse nlswork, clear
(National Longitudinal Survey.  Young Women 14-26 years of age in 1968)

. groups union race , show(f F p P) sepby(union)

  +--------------------------------------------------+
  | union    race   Freq.     #<=   Percent      %<= |
  |--------------------------------------------------|
  |     0   white   10777   10777     56.02    56.02 |
  |     0   black    3784   14561     19.67    75.69 |
  |     0   other     167   14728      0.87    76.56 |
  |--------------------------------------------------|
  |     1   white    2817   17545     14.64    91.20 |
  |     1   black    1649   19194      8.57    99.77 |
  |     1   other      44   19238      0.23   100.00 |
  +--------------------------------------------------+

必须先安装该命令,然后才能使用它。 groups 是一个糟糕的搜索词,但这个 search 会找到 2017 年的文章和以后的软件更新(在撰写本文时,只有 2018 年的一个)。

. search st0496, entry

Search of official help files, FAQs, Examples, and Stata Journals

SJ-18-1 st0496_1  . . . . . . . . . . . . . . . . . Software update for groups
        (help groups if installed)  . . . . . . . . . . . . . . . .  N. J. Cox
        Q1/18   SJ 18(1):291
        groups exited with an error message if weights were specified;
        this has been corrected

SJ-17-3 st0496  . . . . .  Speaking Stata: Tables as lists: The groups command
        (help groups if installed)  . . . . . . . . . . . . . . . .  N. J. Cox
        Q3/17   SJ 17(3):760--773
        presents command for listing group frequencies and percents and
        cumulations thereof; for various subsetting and ordering by
        frequencies, percents, and so on; for reordering of columns;
        and for saving tabulated data to new datasets

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-23
    • 1970-01-01
    • 2014-06-07
    • 2011-10-09
    相关资源
    最近更新 更多