help tfv

Title

tfv -- Transformations of variables

Syntax

tfv [, options :] command

tfv [, options :]
tfvterm
[tfvterm ...]

where command is a Stata command including
tfvterms

a tfvterm is one of

tfvterm corresponding generate command

t(fcn).varname generate fcn_varname = fcn(varname)
t.(exp) generate exp = exp

in new variable names all characters in fcn and exp not
allowed in names are changed to underscore

fcn is typically the name of a math function or
string function taking one argument and typed without
parentheses

exp is an expression or function that typically contains
the name of the variable to be transformed

Description

tfv creates transformations of variables and executes a
specified command with the transformed variables. If no command is
specified tfv creates transformations of variables and adds
them to the current dataset.

Variables previously created by tfv are replaced if specified
repeatedly, but see option noreplace.

Any command not containing tfvterms and specified without a
prefix, varlist, if and in qualifiers
weights and options (e.g. describe)
applies to all variables previously created by tfv.

Options

generate(namelist) specifies variable names for the
corresponding tfvterms. Default names are used for additional
tvfterms, while additional names are ignored.

stub(stub) creates new variables stub1,
stub2, ..., stubk.

noreplace does not replace variables perviously created by
tfv.

type(type) specifies storage
type for created variables.

drop drops all variables previously created by tfv.

tfv and factor variable notation

tfv may be used together with Stata's
factor variable notation. Factor variable operators
are specified before the t. operator.

Examples

. sysuse auto

. tfv summarize price t(ln).price

. tfv ,generate(lnprice) : summarize price t(ln).price

. tfv tabulate t(strlower).make in 1/10

. tfv regress t(ln).price c.t.(mpg/100)##c.t.(mpg/100)

. tfv regress t(ln).price c.t.(mpg/100)##c.mpg_100

. tfv summarize i.t.(rep78 > 3 if !mi(rep78))

. tfv describe

Saved results

tfv saves the following in s():

s(tfvvarlist) variables created by the last tfv call

tfv also saves the following characteristics

_dta[_tfv_varlist] variables created by tfv

varname[_istfv] true if varname has been
created by tfv

Acknowledgments

tfv is inspired by a discussion on
Statalist
as well as official Stata's factor variables
and their predecessor xi.

Author

Daniel Klein, University of Kassel, klein.daniel.81@gmail.com

Also see

Online: fvvarlist, xi