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, statalist.org 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 <maartenlbuis@gmail.com>
To   statalist@hsphsun2.harvard.edu
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:
>
> OnlineChoice.com, 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
"OnlineChoice.com, Inc. (Exelon Corporation (NYSE:EXC))"
"Peppers & Rogers Group (TeleTech Holdings Inc. (NasdaqGS:TTEC))"
end

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

list
*-------------------------- end example ---------------------------
(For more on examples I sent to the Statalist see:
 http://www.maartenbuis.nl/example_faq )

Hope this helps,
Maarten

---------------------------------
Maarten L. Buis
WZB
Reichpietschufer 50
10785 Berlin
Germany

http://www.maartenbuis.nl
---------------------------------
*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index