Drop variables if and only if varnames specified in full
safedrop namelist
Description
safedrop drops the variable(s) named in namelist if and only if every element of namelist is a fully spelled out variable name.
Remarks
Suppose (1) you want to drop variable myvar if and only if that variable exists with exactly that name; (2) there is just one variable in your dataset whose name begins with myvar, namely myvariable. As myvar is an unambiguous abbreviation of myvariable, both drop myvar and capture drop myvar will cause myvariable to be dropped. safedrop myvar is a way to ensure that this does not happen.
Examples
. safedrop myvar
. safedrop myvar yourvar
Author
Nicholas J. Cox n.j.cox@durham.ac.uk
Also see