-------------------------------------------------------------------------------
help for creplace                                                (Roger Newson)
-------------------------------------------------------------------------------

Exchange values cyclically between variables

creplace [ varlist ] [if] [in] [ , previous ]

Description

creplace is an extended version of replace, which exchanges values cyclically between variables in a list of two or more variables. By default, the values in each variable are replaced by values from the next variable in the list, or by values from the first variable, in the case of the last variable. Optionally, the values in each variable are replaced by values from the previous variable in the list, or by values from the last variable, in the case of the first variable. If there are only two variables in the list, then their values will simply be exchanged. Variables in the list must be all numeric or all string. After exchanging the values, creplace will compress these variables to the smallest storage type possible without loss of information.

Options for creplace

previous specifies that the values of each variable in the list will be replaced by values from the previous variable in the list, or by values from the last variable in the list, in the case of the first variable in the list. If previous is not specified, then the values of each variable in the list will be replaced by values from the next variable in the list, or by values from the first variable in the list, in the case of the last variable in the list.

Remarks

creplace can cyclically exchange values between a list with any number of variables greater than one. However, in most cases, there will only be two variables, and their values will be exchanged pairwise, at least in the subset of observations specified by the if and in qualifiers.

creplace is commonly used in output datasets (or resultssets) produced by the parmest package, downloadable from SSC. Such output datasets have one observation for each of a set of estimated parameters, and data on estimates and lower and upper confidence limits, which are stored in three variables. The user may replace the values of these variables to perform an end point transformation on the confidence intervals. If the end point transformation is decreasing, then the user may use creplace to exchange values of the lower and upper confidence limits, after the transformation has been performed.

Examples

.creplace weight length headroom

.creplace weight length headroom, previous

.creplace min95 max95

.creplace min95 max95 if parm=="length"

Author

Roger Newson, National Heart and Lung Institute, Imperial College London, UK. Email: r.newson@imperial.ac.uk

Also see

Manual: [D] generate

Help: [D] replace, [D] generate parmest if installed