.- help for ^erep^ .- Extensions to replace --------------------- ^erep^ [type] newvar ^=^ fcn^(^stuff^)^ [^if^ exp] [^in^ range] [^,^ options] Description ----------- ^erep^ replaces newvar of the optionally specified storage type equal to fcn(stuff). Depending on fcn(), stuff refers to an expression, varlist, or a numlist and the options are similarly function dependent. Note that ^erep^ may change the sort order of your data. ^erep^ functions -------------- ^count(^exp^)^ [^,^ ^by(^varlist^)^] creates a constant (within varlist) containing the number of nonmissing observations of exp. Also see ^robs()^ and ^rmiss()^ below. ^diff(^varlist^)^ creates an indicator variable equal to 1 where the variables in varlist are not equal and 0 otherwise. ^fill(^numlist^)^ creates a variable of ascending or descending numbers or complex repeating patterns. numlist must contain at least two numbers and may be specified using standard numlist notation; see help @numlist@. To create a complex repeating pattern, the pattern should be listed exactly twice. [^if^ exp] and [^in^ range] are not allowed with ^fill()^. ^group(^varlist^)^ [^,^ ^m^issing] returns values 1, 2, ..., for the groups formed by varlist. varlist may contain string, numeric, or both string and numeric variables. ^missing^ indicates that missing values in varlist (either ^.^ or "") are to be treated like any other value when assigning groups instead of missing values being assigned to the group missing. ^iqr(^exp^)^ [^,^ ^by(^varlist^)^] creates a constant (within varlist) containing the interquartile range of exp. Also see ^pctile()^. ^ma(^exp^)^ [^,^ ^t(^#^)^ ^nom^iss] creates a #-period moving average of exp. If ^t()^ is not specified, ^t(3)^ is assumed. # must be odd and exp must not produce missing values. Since moving averages are functions of lags and leads, ^ma()^ produces missing where the lags and leads do not exist -- at the beginning and end of the series. ^nomiss^ forces calculation of shorter, uncentered moving averages for the tails. [^if^ exp] is not allowed with ^ma()^. ^max(^exp^)^ [^,^ ^by(^varlist^)^] creates a constant (within varlist) containing the maximum value of exp. Also see ^min()^. ^mean(^exp^)^ [^,^ ^by(^varlist^)^] creates a constant (within varlist) containing the mean of exp. Also see ^sd()^. ^median(^exp^)^ [^,^ ^by(^varlist^)^] creates a constant (within varlist) containing the median of exp. Also see ^pctile()^. ^min(^exp^)^ [^,^ ^by(^varlist^)^] creates a constant (within varlist) containing the minimum value of exp. Also see ^max()^. ^mtr(^yr inc^)^ returns the U.S. marginal income tax rate for a married couple with taxable income inc in year yr, 1930 <= yr <= 1997. yr and inc may be spec- ified as variable names or constants; e.g., ^mtr(surveyyr 28000)^, ^mtr(1993 faminc)^, or ^mtr(surveyyr faminc)^. Note that a blank, not a comma, separates yr from inc. ^pctile(^exp^)^ [^,^ ^p(^#^)^ ^by(^varlist^)^] creates a constant (within varlist) containing the #-th percentile of exp. If ^p()^ is not specified, 50 is assumed, mean- ing medians; also see ^median()^. # may range from 1 to 99. ^rank(^exp^)^ [^,^ ^by(^varlist^)^] creates ranks (within varlist) of exp; equal observa- tions are assigned the average rank. This function changes the sort order of your data. ^rfirst(^varlist^)^ gives the first nonmissing value in varlist for each observa- tion (row). If all values in varlist are missing for an observation, newvar is set to missing. ^rlast(^varlist^)^ gives the last nonmissing value in varlist for each observation (row). If all values in varlist are missing for an observation, newvar is set to missing. ^rmax(^varlist^)^ gives the maximum value (ignoring missing values) in varlist for each observation (row). If all values in varlist are missing for an obser- vation, newvar is set to missing. ^rmean(^varlist^)^ creates the (row) means of the variables in varlist, ignoring missing values. For example, if three variables are specified and, in some observations, one of the variables is missing, in those observations newvar will contain the mean of the two variables that do exist. Other observa- tions will contain the mean of all three variables. Where none of the var- iables exist, newvar is set to missing. ^rmin(^varlist^)^ gives the minimum value in varlist for each observation (row). If all values in varlist are missing for an observation, newvar is set to missing. ^rmiss(^varlist^)^ gives the number of missing variables in varlist for each obser- vation (row). String variables -- if specified -- are counted as con- taining missing when their value is ""; numeric variables are counted as containing missing when their value is ^.^ . ^robs(^varlist^)^ [^, s^trok] gives the number of nonmissing variables in varlist for each observation (which is the value used by ^rmean()^ for the denominator of the mean calculation). String variables may not be specified unless option ^strok^ is also specified. If ^strok^ is specified, string variables will be counted as containing missing values when they contain ""; numeric variables will be counted as containing missing when their value is ^.^, as usual. ^rsd(^varlist^)^ creates the (row) standard deviations of the variables in varlist, ignoring missing values; see ^rmean()^ above. ^rsum(^varlist^)^ creates the (row) sum of the variables in varlist, treating missing as 0. ^sd(^exp^)^ [^,^ ^by(^varlist^)^] creates a constant (within varlist) containing the standard deviation of exp. Also see ^mean()^. ^std(^exp^)^ [^,^ ^m^ean^(^#^)^ ^s^td^(^#^)^] creates the standardized values of exp. Options specify the desired mean and standard deviation. The default is ^mean(0)^ ^std(1)^, producing a mean 0, standard deviation 1 variable. ^sum(^exp^)^ [^,^ ^by(^varlist^)^] creates a constant (within varlist) containing the sum of exp. Also see ^mean()^. Also see -------- Manual: ^[R] egen^ - there is no manual entry for ^erep^ On-line: help for @collapse@, @functions@, @generate@, @replace@