Title

varelist - extended varlist

Description

A varelist is a superset of a Stata varlist. The differences can be safely ignored if you like.

The three differences are:

1) Repeated variables -- which are only selected once

2) Ranges -- which are more expansive

3) Modifiers -- which are bits set off in parentheses

Repeated Variables

In the following, consider the dataset arch-bromide-carpet:

o- The results of a varelist will include each selected variable only once, no matter how many times it is specified. tlist a a would display a single column of arch, not two columns.

o- A variable will show up in the first place it is specified. For example, tlist * b would display arch bromide carpet, while tlist b * would display bromide arch carpet.

o- A variable is modified, or operated upon, only in its first occurrence. For example:

finddata key using afile, copy(arch->bromide *)

would copy all variables, renaming arch to bromide. But, if the command were written copy(* arch->bromide), arch would not be renamed.

Ranges

Ranges extend a standard stata varlist range in two ways:

o- Endpoints can be specified in either order. Both tlist a-z and tlist z-a would yield the alphabet.

o- Ranges can be combined with wildcards. When a wildcard is included, the most extreme variables found are used as the endpoint(s).
tlist b*-y* would find all variables that start with either b or y, choose the first and last, and list everything between them (inclusive).

Modifiers

In general, a modifier is anything enclosed in parentheses ( ), and modifies either:

o- whatever is touching the opening or closing paren (either is allowed, but not both), or

o- if nothing is touching a paren, everything that follows the modifier, until another modifier (or modified variable/range) is reached.

For example:

a(mod1) mod1 affects a

b*(mod2) mod2 affects all variables starting with b

a-z() The empty modifier affects all variables in the range a to z

(mod3) a b c* h-k(mod4) mod3 affects a, b, and c*; mod4 affects range h-k.

Modifiers are specific to certain commands. If a command does not describe any modifiers, none are allowed. When any modifiers are allowed, empty parens - () - can be used to specify no modifier.