.- help for ^defv^ [STB-40: dm50; STB-51: dm50.1] .- . Define variables and record their definitions --------------------------------------------- . ^defv^ [^by^ varlist^:^] [type] newvar [^:^ lblname] ^=^ exp [^if^ exp] [^in^ range] ^defv^ [^by^ varlist^:^] oldvar ^=^ exp [^if^ exp] [^in^ range] [^, nop^romote] ^defv^ oldvar ^?^ ^defv^ ^?^ . . Description ----------- . ^defv^ creates a new variable or changes the contents of an existing variable, whichever is appropriate, and records the operation it performed in a charac- teristic attached to the variable. The first syntax above is applicable in the case of a new variable, the second and third apply to existing variables. Aside from the positioning of a ^by^ clause (i.e., following rather than preceding the command name), the first syntax is identical to that of the @generate@ command, the second to that of the @replace@ command. ^defv^ is a wrapper for the built-in commands ^generate^ and ^replace^ that makes it possible to define a variable and record its definition by repeatedly using a single command (^defv^), regardless of whether the variable exists at the outset. The definition is recorded in a series of ^characteristics^ associated with the variable (one characteristic for each use of ^defv^); the third syntax above dis- plays those characteristics, in the order recorded. The fourth syntax serves as a reminder of the first three. ^defv^ may be freely used in place of ^generate^ and ^replace^, with two alterations: (1) a ^by^ clause follows the name ^defv^, whereas it precedes the names ^generate^ and ^replace^; (2) the name of the variable being defined cannot be abbreviated. . Options ------- . . There are no options other than those associated with ^generate^ and ^replace^. . However, it is possible to alter the style in which ^defv^ records definitions. By default, ^defv^ uses the same naming scheme as the command @notes@, so that re- corded definitions will appear to have been created by ^notes^. Definitions from ^defv^ and notes from ^notes^ may be freely intermingled. If this is undesirable, definitions can be rendered distinct from notes by altering a comment line near the top of the file defv.ado. . Examples -------- . . . ^defv age2 = age*age^ . ^defv income=. if income<=0^ . ^defv byte biginc = income>100000 & income~=.^ . ^defv xlag = x[_n-1] in 2/l^ . . ^replace sw = 1 if region=="SW"^ (OK) . ^defv sw = 1 if region=="SW"^ (Also OK) . . ^sort loc^ . ^defv by loc: avgx = sum(x)/sum(x~=.)^ . ^defv by loc: avgx = avgx[_N]^ . ^defv avgx ?^ . Author ------ . . John R. Gleason, Syracuse University, Syracuse NY, USA (loesljrg@@accucom.net) [This is Version 1.1.3 (06Mar1999).] . Also see -------- . . Manual: ^[U] 19 Data^ ^[U] 19.8 Characteristics^ ^[U] 20 Functions and expressions^ ^[R] generate^ ^[R] notes^ . On-line: help for @char@, @datatypes@, @exp@, @functions@, @generate@, @notes@, @operators@