|
Size: 1399
Comment:
|
← Revision 3 as of 2025-10-24 17:10:03 ⇥
Size: 1237
Comment: Rewrite
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 3: | Line 3: |
| The '''`ds`''' command lists variables. | '''`-ds-`''' lists variables. |
| Line 13: | Line 13: |
| Used alone, `ds` will simply return the given variable list. | By default, `-ds-` simply returns the given variable list. |
| Line 19: | Line 19: |
| To list all variables ''other than'' `foo`, `bar`, and `baz`, try the '''`not`''' option: | To list all variables not included in a given variable list, try the '''`not`''' option: |
| Line 25: | Line 25: |
| Variables can be described by a specification and `ds` will return the list of variables matching (or not matching) it. | === Specification === Variables can be described by a specification and `-ds-` will return the list of variables matching (or not matching) it. |
| Line 29: | Line 33: |
| Line 31: | Line 36: |
---- == Specifications == |
|
| Line 42: | Line 41: |
| * For example, `format %t*` selects all variables with a [[Stata/DataFormats#Date_and_Datetime_Data|datetime display format]] | |
| Line 43: | Line 43: |
| * For example, `varlabel *temp*` selects all variables with a variable label including the word 'temp' | |
| Line 45: | Line 46: |
Types are any of the [[Stata/DataTypes|data types]] plus categories like `string`, `str#`, and `numeric`. Patterns look like `%t*` (as in `format %t*`, which selects all variables with a [[Stata/DataFormats#Date_and_Datetime_Data|datetime display format]]) or `*weight*` (as in `varlabel *weight*`, which selects all variables with a variable label including the word 'weight'). |
|
| Line 64: | Line 61: |
| [[https://www.stata.com/manuals/dds.pdf|Stata manual for ds]] | [[https://www.stata.com/manuals/dds.pdf|Stata manual for -ds-]] |
Stata Ds
-ds- lists variables.
Contents
Usage
By default, -ds- simply returns the given variable list.
ds foo bar baz
To list all variables not included in a given variable list, try the not option:
ds foo bar baz, not
Specification
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)
Valid specifications for the spec(spec) and not(spec) options are:
type typelist
format patternlist
For example, format %t* selects all variables with a datetime display format
varlabel patternlist
For example, varlabel *temp* selects all variables with a variable label including the word 'temp'
vallabel patternlist
char patternlist
Stored Results
The list of selected variables is stored in r(varlist), without any truncation or indentation.
