.- help for ^genl^, ^repl^, ^redo^, ^defntion^ Jeroen Weesie & Albert Verbeek/ICS Jan 03, 1997 .- Defined variables with automatic variable labels [STB-35: dm43] ------------------------------------------------ ^genl^ [type] newvar ^=^ exp [^if^ exp] [^in^ range] [^,^ ^by(^varlist^) l^abel^(^str^)^ ^nod^ef ] ^repl^ oldvar ^=^ exp [^if^ exp] [^in^ range] [^,^ ^by(^varlist^) l^abel^(^str^)^ ^o^ldlabel ^nod^ef ] ^redo^ varlist ^defntion^ [varlist] [, ^o^ther] Description ----------- ^genl^ and ^repl^ are enhancements of Stata's commands ^generate^ and ^replace^. - the definition for a variable is saved as the characteristic ^Defntion^ associated with that variable. Thus, definitions of variables are saved along with your data! The definition comprises the defining expression, the case restrictions -if- and -in-, and the -by varlist- clause. - ^genl^ and ^repl^ use the defining expression to label the variable. So you record how the variable was constructed. If the expression is too long, the label is truncated and "..." is added. ^redo^ uses the characteristic ^Defntion^ to redefine the variables in the order implied by varlist. With some inspiration (and additional respiration), a poor man's spreadsheet can be constructed. ^defntion^ displays the definitions of the variables. Options ------- ^label(^string^)^ specifies the label of the variable instead of the defining expression. Specify ^label(_)^ to force an empty label. Specifying a label not does affect the definition of the charactistic Defntion. ^nodef^ suppresses the generation (^genl^) or modification (^repl^) of the characteristic Defntion. ^oldlabel^ specifies that the label of the variable should not be changed. ^by(^varlist^)^ specifies that the expression should be evaluated "by varlist:". The sort order of the variables is changed only if needed. ^other^ specifies that ^defntion^ includes variables without a definition. Examples -------- . ^genl age = Tnow - Tbirth^ creates age with label "D: Tnow - TBirth" . ^genl N = invnorm(uniform())^ creates a normal variate . ^genl M = N^^2+N+1, label(own label)^ supply own label . ^defntion^ list the defined-variables Since ^N^ is defined using (pseudo-)random number, re-evaluating the expression generates new values for ^N^, . ^redo N^ Note though that the variable ^M^ was defined in terms of ^N^. Since ^genl^ stored the definition of ^M^, it is possibly to update ^M^ .^ redo M^ Since variables are updated in the specified order, it would have been easier to have issued the command . ^redo N M^ redraw a normal variate for ^N^, and update ^M^ accordingly Acknowledgement --------------- The commands ^genl^, ^repl^, ^redo^, and ^defntion^ are extensive updates of early versions in the ETS-Kit, a collection of Stata programs written for Stata 2.1 by the late Albert Verbeek and Jeroen Weesie. See also -------- STB: dm43 (STB-35) Manual: [R] generate [R] label On-line: help for @generate@, @replace@, @char@