Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
st: Minor bug in -labvalclone- by NJC
From
Sergiy Radyakin <[email protected]>
To
"[email protected]" <[email protected]>
Subject
st: Minor bug in -labvalclone- by NJC
Date
Thu, 21 Nov 2013 19:45:26 -0500
Bug in -labvalclone- by NJC
http://fmwww.bc.edu/repec/bocode/l/labvalclone.ado
===Example:
clear
label define a 1 "US" 2 "UK" 3 "UA"
labvalclone a aa
===Output:
unrecognized command: laabel
r(199);
===Why does it happen:
Because replacing blindly code is not safe. Nick is trying to check
for this problem by having a safety check of the old argument earlier
in the program:
if "`old'" == "label" | "`old'" == "define"
but later is doing a replacement of a SUBSTRING, not a WORD-by-word replacement.
===Suggested fix:
Simply flank both args (old and new) with spaces:
local line: subinstr local line " `old' " " `new' "
Best,
Sergiy Radyakin
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/