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]

st: New package -moss- available from SSC


From   Robert Picard <[email protected]>
To   [email protected]
Subject   st: New package -moss- available from SSC
Date   Mon, 28 Mar 2011 12:29:45 -0400

Thanks to Kit Baum, a new package -moss-, coauthored with Nick Cox, is
now available from SSC. -moss- finds multiple occurrences of
substrings. To install, type:

ssc install moss

-moss- can be used to search for a simple pattern of text. For example:

moss mystrvar, match("hello")

will find all occurrences of "hello" for each observations of the
string variable mystrvar.  -moss- creates a variable with the count of
occurrences and as many variables as necessary to indicate the
position of each match.

-moss- can also be used to search for more complex patterns of text
using regular expressions. With the -regex- option, -moss- creates
additional variables for each subexpression matched. For example, to
find all occurrences of one or more digits:

. moss mystrvar, match("([0-9]+)") regex

To find runs of the letter X:

. moss history, match("(X+)") regex

To match anything delimited by commas:

. moss mystrvar, match("([^,]+)") regex

-moss- is the result of a collaboration between Nick Cox and myself
that stemmed from a Statalist query by Rebecca Pope about finding the
position of the longest run of "X" within a string variable.

Cheers.

Robert
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


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