-------------------------------------------------------------------------------
help for varlocal
-------------------------------------------------------------------------------

Title

varlocal varlist [if exp] [in exp] [, separate(string) replacespace nomissing ]

Description

varlocal transform values of a variable in local. The order is the same as the sort of the variable in the dataset and repeated value of the variable is kept.

Options

separate(string) separator to serve as punctuation for the values of returned list; default is a space.

replacespace it is useful for string variable that has two or more words as value. It replaces the space between word by underscore character, _.

nomissing does not include missing values of varlist in calculation.

Saved Results

varlocal returns results in r() format. By typing return list, the following results are reported:

Macros r(varname) list of values of one variable listed in varlist.

Obs: The reported local has the correspondent name of the variables in varlist

Examples

. sysuse auto, clear

. varlocal mpg

. varlocal mpg in 10

. varlocal mpg in 1/10, separate(;)

. varlocal make if mpg<15, replacespace

. varlocal make rep78, nomissing . return list

Consider the folling variable var = 1,1,2,1,3,4,7,11,... varlocal can be used to return the variable value in a determined position . varlocal var in 5 . local a `r(var)'

the local a would be equal to 3

Author

Viviane Sanfelice, World Bank, sanfelicev@gmail.com

Also see

Online: help for levelsof