help countvalues

Title

countvalues -- List counts of integer values across variables

Syntax

countvalues [varlist]
[if] [in]
,
values(numlist)
[
variablelabels
sort(specification)
rowspositive
colspositive
saving(filespec)
list_options
]

Description

countvalues lists counts of specified integer values
across one or more numeric variables. Missing values may be specified.

countvalues ignores any string variables specified,
whether directly or indirectly.

Options

values() specifies distinct integer values that are to be
counted. It is a required option.

variablelabels specifies display of variable labels
rather than variable names. If no variable label has been defined, the
variable name is shown instead.

sort(specification) specifies that output is to be
displayed sorted. The specification may include the keywords
names, labels and descending, either in full or as
any abbreviation. The specification may also include any one of the
values specified in values() to stipulate that output should be
sorted on the column containing counts of that value.

names specifies sorting on variable names.

labels specifies sorting on variable labels.

descending specifies that output is to be displayed
sorted, but in reverse order. Hence for example if sorting is by counts
of a specified value, the largest number will be first, which may be
useful; if sorting is on variable names or variable labels, ordering is
(for example) z before a before _ before Z before A, which seems less
likely to be useful but is allowed any way.

rowspositive specifies that only rows containing one or
more positive counts for the variable concerned should be displayed.
Note that this may result in no list being displayed.

colspositive specifies that only columns containing one
or more positive counts for the value concerned should be displayed.
Note that this may result in no list being displayed.

saving() specifies that the data listed should be saved
as a Stata dataset. To overwrite an existing dataset, use
saving(filename, replace). The dataset will include both
variable names and variable labels, regardless of whether
variablelabels has been specified.

list_options are options of list, which is used to
display results. Defaults include separator(0) noobs.

Remarks

Possible applicatios include summary tabulation of

* indicator variables, say those with values 0, 1 or missing

* grade variables, say those with responses from 1 to 5

* missing values, whether orthodox system missing . or any of
.a to .z or idiosyncratic codes for missings such as -999

Examples

. sysuse auto, clear

. countvalues, values(.)

. countvalues, values(.) rowspos

. webuse nlswork, clear

. findname, all(inlist(@, 0, 1, .)) local(myvars)

. countvalues `myvars', values(0 1 .)

. countvalues `myvars', values(0 1 .) variablelabels sort(1 desc)

Author

Nicholas J. Cox, Durham University, UK

n.j.cox@durham.ac.uk

Also see

Online:
[R] tabulate_oneway,
[R] tabulate_twoway,
[R] table,
findname (Stata Journal; if installed),
groups (Stata Journal; if installed),
missings (Stata Journal; if installed),
tabcount (SSC; if installed),
tabm (SSC; if installed)