Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

Re: st: clonevar

From   Richard Williams <[email protected]>
To   [email protected]
Subject   Re: st: clonevar
Date   Mon, 11 Oct 2004 22:48:44 -0500

At 10:07 PM 10/11/2004 -0500, you wrote:
At 09:52 PM 10/11/2004, you wrote:
At 09:29 PM 10/11/2004 -0500, Fred Wolfe wrote:
-clonevar- reports an error incorrectly:
What is -clonevar-? It doesn't seem to be a built-in command nor can I -findit-. Perhaps it comes with some package of routines? If so, you may want to contact the author directly.
It was a new Stata command that came with the last update/upgrade. Try h whatsnew.
Ok, got it. -clonevar.ado- includes these lines:

capture confirm new var `newvar'
if _rc | ("`eqs'" != "=") Badsyntax

capture confirm var `varname'
if _rc Badsyntax

If I'm reading this right, the first capture confirm checks whether there already is a variable with the new name you want to use (and also whether you have an = sign?). The 2nd capture confirm checks whether the old variable you want to clone exists. If any of these checks produces an error, then this code gets executed:

program Badsyntax
di "{p}{err}syntax is {cmd:clonevar {it:newvar} = {it:varname}} ...{p_end}"
exit 198

So, if you wanted more descriptive error messages, you could do something like create multiple Badsyntax programs with the messages you wanted. As it stands, I agree that the current error message isn't too descriptive (but the command itself seems like a very nice addition to Stata).

Richard Williams, Notre Dame Dept of Sociology
OFFICE: (574)631-6668, (574)631-6463
FAX: (574)288-4373
HOME: (574)289-5227
EMAIL: [email protected]
WWW (personal):
WWW (department):

* For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index