Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, is already up and running.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: extract string portion

From   Maarten Buis <>
Subject   Re: st: extract string portion
Date   Tue, 27 Nov 2012 11:33:38 +0100

On Tue, Nov 27, 2012 at 11:14 AM, thomas bourveau wrote:
> I am working on a dataset where I need to extract an identifier for
> the parent company of my observations. Here are two examples:
>, Inc. (Exelon Corporation (NYSE:EXC))
> Peppers & Rogers Group (TeleTech Holdings Inc. (NasdaqGS:TTEC))
> As you can see the dataset provides the name of the company, its stock
> exchange and its identifier (the Ticker) in the same row.
> I'm interested in retrieving the Ticker (EXC and TTEC in the
> abovementioned examples).

For more see: -help string functions-

*------------------------- begin example --------------------------
drop _all
input str63 company
", Inc. (Exelon Corporation (NYSE:EXC))"
"Peppers & Rogers Group (TeleTech Holdings Inc. (NasdaqGS:TTEC))"

gen begin = strpos(company,":")+1
gen end = length(company) - 1
gen ticker = substr(company,begin,end-begin)

*-------------------------- end example ---------------------------
(For more on examples I sent to the Statalist see: )

Hope this helps,

Maarten L. Buis
Reichpietschufer 50
10785 Berlin
*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index