Recently I've had a recurring problem when manipulating ID variables in a dataset. The problem occurs when I generate a clone of a variable, the new variable does not retain the formatting of the original. For example:
Here assert returns an error, presumably because id is stored as %10.0g (double) while newvar is %9.0g (float).
Is there a way that I can require newvar to conform to the formatting of id, without hard-coding the format?
(Running STATA 14 64-bit on Win 7)
Thanks,
Mike
Code:
sysuse auto gen id = string(price) + string(length) + string(weight) destring id, replace gen newvar = id assert id == newvar
Is there a way that I can require newvar to conform to the formatting of id, without hard-coding the format?
(Running STATA 14 64-bit on Win 7)
Thanks,
Mike
Comment