Bookmark and Share

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]

Re: st: Use of subinword in Stata 13 vs. Stata 12


From   [email protected] (Vince Wiggins, StataCorp)
To   [email protected]
Subject   Re: st: Use of subinword in Stata 13 vs. Stata 12
Date   Fri, 19 Jul 2013 14:55:46 -0500

Dirk Enzmann <[email protected]> writes that the subinword()
function, when the string to be substituted for is empty, behaves
differently in version 12 than it does in version 13. (See details of
Dirk's post below my signature.)

In version 12, an empty string is always returned.  In version 13, the
original string is returned untouched.  As Robert Picard
<[email protected]> notes, the Stata 12 behavior in wrong.  An
empty string does not match any of the characters in the original
string and therefore there are no substitutions to be made.  That is what
Stata 13 does.

Asking to match on an empty string is, in one sense, a poorly formed
expression.  Such expressions still occur all the time in programming,
as a degenerate case.

We will look into updating the subinword() function in Stata 12.


-- Vince 
   [email protected]



------------ Original message ---------------------------

When trying to use -subinword()-, I get different results in Stata 13 as 
compared to Stata 12 (or 11, or 10). Example:

* --- Start Stata commands: ---------------

local vlist = "trunk"
local generate = ""
di subinword("`vlist'","`generate'"," ",.)

* --- End Stata commands. -----------------

Using version 13 the -display- command in the third line shows

trunk

(which I expect), whereas version 12 (or 11 or 10) shows

nothing. Why does the replacement of the occurance of "" in "trunk" 
yields ""? And why does version 13 yield "trunk"?
 
<end>
*
*   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/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index