help ds dialog: ds
previously documented
-------------------------------------------------------------------------------
ds continues to work but, as of Stata 9, is no longer an official part of
Stata. This is the original help file, which we will no longer update,
so some links may no longer work.
Title
[D] ds -- List variables matching name patterns or other characteristics
Syntax
Simple syntax
ds [, alpha]
Advanced syntax
ds [varlist] [, options]
options description
-------------------------------------------------------------------------
Main
not describe variables not in varlist
alpha list variables in alphabetical order
detail display additional details
varwidth(#) display width for variable names; default is
varwidth(12)
skip(#) gap between variables; default is skip(2)
Advanced
has(spec) describe subset that matches spec
not(spec) describe subset that does not match spec
+ insensitive perform case-insensitive pattern matching
+ indent(#) indent output; seldom used
-------------------------------------------------------------------------
+ insensitive and indent(#) are not shown in the dialog box.
spec description
-------------------------------------------------------------------------
type typelist specified types
format patternlist display format matching patternlist
varlabel [patternlist] variable label or variable label matching
patternlist
char [patternlist] characteristic or characteristic matching
patternlist
vallabel [patternlist] value label or value label matching patternlist
-------------------------------------------------------------------------
typelist used in has(type typelist) and not(type typelist) is a list of
one or more types, each of which may be numeric, string, byte, int,
long, float, or double, or may be a numlist such as 1/8 to mean
"str1 str2 ... str8". Examples include
has(type int) is of type int
has(type byte int long) is of integer type
not(type int) is not of type int
not(type byte int long) is not of the integer types
has(type numeric) is a numeric variable
not(type string) is not a string variable (same as
above)
has(type 1/40) is str1, str2, ..., str40
has(type numeric 1/2) is numeric or str1 or str2
patternlist used in, for instance, has(format patternlist), is a list of
one or more patterns. A pattern is the expected text with the
addition of the characters * and ?. * indicates 0 or more characters
go here, and ? indicates exactly 1 character goes here. Examples
include
has(format *f) format is %#.#f
has(format %t*) has time or date format
has(format %-*s) is a left-justified string
has(varl *weight*) variable label includes word weight
has(varl *weight* *Weight*) variable label has weight or Weight
To match a phrase, enclose the phrase in quotes.
has(varl "*some phrase*") variable label has some phrase
If instead you used has(varl *some phrase*), then only variables having
labels ending in some or starting with phrase would be listed.
Description
ds lists variable names of the dataset currently in memory in a compact
or detailed format, and lets you specify subsets of variables to be
listed, either by name or by properties (e.g., the variables are
numeric). In addition, ds leaves behind in r(varlist) the names of
variables selected so that you can use them in a subsequent command.
ds, typed without arguments, lists all variable names of the dataset
currently in memory in a compact form.
Options
+------+
----+ Main +-------------------------------------------------------------
not specifies that varlist contain the list of variables not be listed.
For instance, ds pop*, not specifies that all variables not starting
with the letters pop be listed. The default is to list all the
variables in the dataset or, if varlist is specified, the variables
specified.
alpha specifies that the variables be listed in alphabetical order.
detail specifies that detailed output identical to that of describe be
produced. If detail is specified, varwidth(), skip(), and indent()
are ignored.
varwidth(#) specifies the display width of the variable names; the
default is varwidth(12).
skip(#) specifies the number of spaces between variable names; the
default is skip(2).
+----------+
----+ Advanced +---------------------------------------------------------
has(spec) and not(spec) select from the dataset (or from varlist) the
subset of variables that meet or fail the specification spec.
Selection may be made on the basis of storage type, variable label,
value label, display format, or characteristics. Only one not,
has(), or not() option may be specified.
has(type string) selects all string variables. Typing ds, has(type
string) would list all string variables in the dataset, and typing
ds pop*, has(type string) would list all string variables whose names
begin with the letters pop.
has(varlabel) selects variables with defined variable labels.
has(varlabel *weight*) selects variables with variable labels
including the word weight. not(varlabel) would select all variables
with no variable labels.
has(vallabel) selects variables with defined value labels.
has(vallabel yesno) selects variables whose value label is yesno.
has(vallabel *no) selects variables whose value label ends in the
letters no.
has(format patternlist) specifies variables whose format matches any
of the patterns in patternlist. has(format *f) would select all
variables with formats ending in f, which presumably would be all
%#.#f, %0#.#f, and %-#.#f formats. has(format *f *fc) would select
all ending in f or fc. not(format %t* %-t*) would select all
variables except those with date or time-series formats.
has(char) selects all variables with defined characteristics.
has(char problem) selects all variables with a characteristic named
problem.
The following options are available with ds but are not shown in the
dialog box:
insensitive specifies that the matching of the pattern in has() and not()
be case insensitive.
indent(#) specifies the amount the lines are indented.
Examples
All variables
. ds
All string variables
. ds, has(type string)
. edit `r(varlist)'
All str1, str2, str3, str4 variables
. ds, has(type 1/4)
All numeric variables
. ds, has(type numeric)
. order `r(varlist)'
. ds, has(type numeric)
. summarize `r(varlist)'
All byte or int variables
. ds, has(type byte int)
All float variables
. ds, has(type float)
All variables that are not float
. ds, not(type float)
All variables with value labels attached
. ds, has(vall)
All variables with the value label origin attached
. ds, has(vall origin)
All date variables, i.e., those with formats %t* or %-t*
. ds, has(format %t* %-t*)
Variables with left-justified string formats
. ds, has(format %-*s)
Variables with comma formats
. ds, has(format *c)
Variables with characteristics defined
. ds, has(char)
Also see
Manual: previously documented
Help: [D] compress, [D] cf, [D] codebook, [D] compare, [D] describe,
[D] format, [D] label, [D] lookfor, [D] notes, [D] order, [D]
rename