*! version 1.0.2 18sep2024

Title

replacen -- Replace contents in exactly n observations.

Syntax

replacen
n
oldvar
=exp
[if] [in]
[, options]

Description

replacen executes the replace command, but checks whether exactly n observations have been modified. If not, an error is issued.

Examples

The first call to replacen will not produce an error. The second, same, call will produce an error as no observations will be modified by the replace command.

. sysuse auto, clear
. replacen 1 price = 0 if make == "AMC Concord"
. replacen 1 price = 0 if make == "AMC Concord"

Author

Hendri Adriaens, Centerdata, The Netherlands.

hendri.adriaens@centerdata.nl