Differences between revisions 1 and 2
Revision 1 as of 2023-06-08 20:15:03
Size: 1389
Comment:
Revision 2 as of 2023-06-08 20:15:28
Size: 1399
Comment:
Deletions are marked like this. Additions are marked like this.
Line 40: Line 40:
 * type typelist
 * format patternlist
 * varlabel patternlist
 * vallabel patternlist
 * char patternlist
 * `type typelist`
 * `format patternlist`
 * `varlabel patternlist`
 * `vallabel patternlist`
 * `char patternlist`

Stata Ds

The ds command lists variables.


Usage

Used alone, ds will simply return the given variable list.

ds foo bar baz

To list all variables other than foo, bar, and baz, try the not option:

ds foo bar baz, not

Variables can be described by a specification and ds will return the list of variables matching (or not matching) it.

ds, spec(type numeric)
ds, not(type string)


Specifications

Valid specifications for the spec(spec) and not(spec) options are:

  • type typelist

  • format patternlist

  • varlabel patternlist

  • vallabel patternlist

  • char patternlist

Types are any of the data types plus categories like string, str#, and numeric.

Patterns look like %t* (as in format %t*, which selects all variables with a datetime display format) or *weight* (as in varlabel *weight*, which selects all variables with a variable label including the word 'weight').


Stored Results

The list of selected variables is stored in r(varlist), without any truncation or indentation.


See also

Stata manual for ds


CategoryRicottone

Stata/Ds (last edited 2023-06-08 20:15:28 by DominicRicottone)