Title

tsame -- Sets of records with the same values

Syntax

tsame [varelist] [if] [in] [, options]

multiple(varelist) Sets with multiple values of other vars

headings(details) Custom column headings

Description

tsame shows counts of records, sets, and records/set, where a set of records is defined by having all the same values in varelist.

With the multiple() option, it will also show how many sets have multiple values of each of the vars in multiple().

tsame may generate a number of variables:

_same - holding the count of records with the same values of varelist

and for each variable Vn in multiple(varelist)

_Vn_2 and/or

_Vn_m - both described under multiple().

Each variable is only generated if it would be informative. For example, _same is only generated if the number of records per set is not uniform.
All generated variables can be dropped with drany.

Options

multiple(varelist) adds columns showing the number of sets that have multiple values of the specified variables. Consider the following dataset:

name alias

Bob Despair
Bob
Ted Ned
Ted Ned
X Missy
X Little Miss
Carol Alice
Carol Carol the Great
Carol Navarth

The output for tsame name would be:

Records | Distinct | Total
per Set | Sets | Records
-----------+--------------+---------
2 | 3 | 6
3 | 1 | 3
-----------+--------------+---------
| 4 | 9

indicating that 3 names are repeated twice, and one name is repeated 3 times.

The output for tsame name, mult(alias) would be:

Records | Distinct | Total
per Set | Sets | Records
| |
| Multiple |
| +---------+
| ¦ alias |
| ¦ p2+ p+m |
-----------+----+---------+---------
2 | 3 ¦ 1 1 | 6
3 | 1 ¦ 1 0 | 3
-----------+----+---------+---------
| 4 ¦ 3 1 | 9

indicating that:

o- Of the 3 names repeated twice, one has multiple 'present' aliases (p2+), and one has both present and missing aliases (p+m).

o- The 1 name repeated three times has multiple present aliases (p2+), and no missing aliases (p+m).

Each column of the multiple() display may be reflected in the data with a corresponding variable, which holds 0 or 1 depending on whether the relevant set of observations contains multiple values.

The example above would result in the following dataset:

name alias _same _alias_2 _alias_m

Bob Despair 2 0 1
Bob 2 0 1
Ted Ned 2 0 0
Ted Ned 2 0 0
X Missy 2 1 0
X Little Miss 2 1 0
Carol Alice 3 1 0
Carol Carol the Great 3 1 0
Carol Navarth 3 1 0

headings(details) allows you to substitute your own text for the top-most column headings -
useful for displaying the meanings in a particular context. For example, 'Visits' and 'Patients' instead of 'Records per Set' and 'Distinct Sets'. The syntax is:

headings( [text] [,][text] [,][text] )

where text before any commas will head the first column (Records per Set), text after the first comma will head the second column (Distinct Sets),
and text after the second column will head the third column (Total Records).

out option specifies output style & destination.