help tabulate, help tab1 dialogs: tabulate
tabulate ..., generate()
tab1
-------------------------------------------------------------------------------
Title
[R] tabulate oneway -- One-way tables of frequencies
Syntax
One-way tables of frequencies
tabulate varname [if] [in] [weight] [, tabulate1_options]
One-way tables for each variable - a convenience tool
tab1 varlist [if] [in] [weight] [, tab1_options]
tabulate1_options description
-------------------------------------------------------------------------
Main
subpop(varname) exclude observations for which varname = 0
missing treat missing values like other values
nofreq do not display frequencies
nolabel display numeric codes rather than value labels
plot produce a bar chart of the relative frequencies
sort display the table in descending order of frequency
Advanced
generate(stubname) create indicator variables for stubname
matcell(matname) save frequencies in matname; programmer's option
matrow(matname) save unique values of varname in matname
-------------------------------------------------------------------------
tab1_options description
-------------------------------------------------------------------------
Main
subpop(varname) exclude observations for which varname = 0
missing treat missing values like other values
nofreq do not display frequencies
nolabel display numeric codes rather than value labels
plot produce a bar chart of the relative frequencies
sort display the table in descending order of frequency
-------------------------------------------------------------------------
by is allowed with tabulate and tab1; see [D] by.
fweights, aweights, and iweights are allowed by tabulate. fweights are
allowed by tab1. See weight.
Menu
tabulate oneway
Statistics > Summaries, tables, and tests > Tables > One-way tables
tabulate ..., generate()
Data > Create or change data > Other variable-creation commands >
Create indicator variables
tab1
Statistics > Summaries, tables, and tests > Tables > Multiple one-way
tables
Description
tabulate produces one-way tables of frequency counts.
For information on two-way tables of frequency counts along with measures
of association, including the common Pearson chi-squared, the likelihood
ratio chi-squared, Cramér's V, Fisher's exact test, Goodman and Kruskal's
gamma, and Kendall's tau-b, see [R] tabulate twoway.
tab1 produces a one-way tabulation for each variable specified in
varlist.
Also see [R] table and [R] tabstat if you want one-, two-, or n-way
tables of frequencies and a wide variety of statistics. See [R]
tabulate, summarize() for a description of tabulate with the summarize()
option; it produces tables (breakdowns) of means and standard deviations.
table is better than tabulate, summarize(), but tabulate, summarize() is
faster. See [ST] epitab for 2 x 2 tables with statistics of interest to
epidemiologists.
Options
+------+
----+ Main +-------------------------------------------------------------
subpop(varname) excludes observations for which varname = 0 in tabulating
frequencies. The mathematical results of tabulate ..., subpop(myvar)
are the same as tabulate ... if myvar != 0, but the table may be
presented differently. The identities of the rows and columns will
be determined from all the data, including the myvar = 0 group, so
there may be entries in the table with frequency 0.
Consider tabulating answer, a variable that takes on values 1, 2, and
3, but consider tabulating it just for male==1 subpopulation. Assume
that answer is never 2 in this group. tabulate answer if male==1
produces a table with two rows: one for answer 1 and one for answer
3. There will be no row for answer 2 because answer 2 was never
observed. tabulate answer, subpop(male) produces a table with three
rows. The row for answer 2 will be shown as having 0 frequency.
missing requests that missing values be treated like other values in
calculations of counts, percentages, and other statistics.
nofreq suppresses the printing of the frequencies.
nolabel causes the numeric codes to be displayed rather than the value
labels.
plot produces a bar chart of the relative frequencies in a one-way table.
(Also see [R] histogram.)
sort puts the table in descending order of frequency (and ascending order
of the variable within equal values of frequency).
+----------+
----+ Advanced +---------------------------------------------------------
generate(stubname) creates a set of indicator variables (stubname1,
stubname2, ...) reflecting the observed values of the tabulated
variable. The generate() option may not be used with the by prefix.
matcell(matname) saves the reported frequencies in matname. This option
is for use by programmers.
matrow(matname) saves the numeric values of the r x 1 row stub in
matname. This option is for use by programmers. matrow() may not be
specified if the row variable is a string.
Examples
---------------------------------------------------------------------------
Setup
. sysuse census
One-way table of frequencies
. tabulate region
Show table in descending order of frequencies
. tabulate region, sort
Create indicator variables for region, called reg1, reg2, ...
. tabulate region, gen(reg)
---------------------------------------------------------------------------
Setup
. sysuse auto, clear
. tabulate rep78
. tabulate foreign
Shorthand for above two commands
. tab1 rep78 foreign
---------------------------------------------------------------------------
Saved results
tabulate and tab1 save the following in r():
Scalars
r(N) number of observations
r(r) number of rows
Also see
Manual: [R] tabulate oneway
Help: [D] collapse, [ST] epitab, [SVY] svy: tabulate oneway, [SVY]
svy: tabulate twoway, [R] table, [R] tabstat, [R] tabulate,
summarize(), [R] tabulate twoway, [XT] xttab