------------------------------------------------------------------------------- help forcreplace(Roger Newson) -------------------------------------------------------------------------------

Exchange values cyclically between variables

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

Description

creplaceis an extended version ofreplace, 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,creplacewillcompressthese variables to the smallest storage type possible without loss of information.

Options forcreplace

previousspecifies 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. Ifpreviousis 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

creplacecan 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 theifandinqualifiers.

creplaceis commonly used in output datasets (or resultssets) produced by theparmestpackage, 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 usecreplaceto 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"

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

Also seeManual:

[D] generateHelp:

[D] replace,[D] generateparmestif installed