.- help for ^vallist^ (STB-60: dm90) .- List distinct values of a variable ---------------------------------- ^vallist^ varname [^if^ exp] [^in^ range] [, ^g^lobal^(^macname^) l^abels ^q^uoted [^no^]^t^rim ^m^ax^(^#^) w^ords ^f^ormat^(^format^) s^ep^(^string^) miss^ing] Description ----------- ^vallist^ puts a sorted list of the distinct nonmissing values of varname, which may be numeric or string, into local macro ^r(list)^ and displays that list. ^vallist^ may be used interactively, but it is most likely to be useful to programmers dealing with categorical or counted data. Remarks ------- Stata itself trims leading spaces in any operation of the form ^local^ macroname = string_variable[i] Trailing spaces are also trimmed by default. Options ------- ^global(^macname^)^ puts the list into global macro macname. ^labels^ specifies that labels should be used for numeric variables with value labels. ^quoted^ specifies that values should be placed in ^" "^. This may be useful for string values or value labels containing embedded spaces. ^notrim^ suppresses trimming of trailing spaces from string values. ^max(^#^)^ specifies that at most, the first # characters of text (string values or value labels) should be used for each value. For example, ^max(8)^ may be needed to cut down text to elements acceptable in Stata 6 as matrix row or column names. ^words^ specifies that text should be truncated to the first whole `word', that is, at just before the first space after a nonspace character. For example, a string value of ^"foo bar"^ would be represented by ^"foo"^. ^format(^format^)^ specifies a format for use. This is likely to be most useful with noninteger numeric values. A string format should be specified for string values or value labels and a numeric format otherwise. ^sep(^string^)^ specifies a separator other than a space, which is the default. The sequence of operations is ^max()^, ^words^, ^format()^, ^sep()^. ^missing^ specifies that missing values should also be listed. Missing (i.e., empty) values of string variables are specified as ^"missing"^. Note that this description may be truncated with the ^max()^ option. Saved results ------------- ^r(list)^ contains the list of distinct values. Examples -------- . ^vallist rep78^ . ^vallist rep78 if foreign, sep(,)^ . ^vallist foreign, labels^ . ^vallist mpg, s(,) g(vals)^ . ^graph mpg, bin(10) xsc(0,50) xti($vals)^ Author ------ Nicholas J. Cox, University of Durham, U.K. n.j.cox@@durham.ac.uk Acknowledgements ---------------- Fred Wolfe suggested that missing values be listable and raised the problem of embedded spaces. Also see -------- On-line: help for @tabulate@, @listutil@ (if installed) Manual: ^[R] limits^