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: Extract identifier in the middle of a string variable


From   Ghislaine Vantomme <[email protected]>
To   [email protected]
Subject   st: Extract identifier in the middle of a string variable
Date   Fri, 14 Dec 2012 13:46:02 +0100

Dear statalist users,

I am currently working with a dataset retrieved from a financial
database, namely IQ Capital.

Within this database, I am interested in international firms that are
cross-listed in the United States. Thus, these firms have multiple
identifiers because each firm has a unique identifier per stock
exchange where it is listed. I need to retrieve only a firm's
idenfitier for the US stock exchange, namely the NYSE.

The string variable where the information is contained is like in
example 1. I've tried to use a mix between substr and strpos commands,
but the results are not fine yet. If you have any idea, it would be
great.

Example 1:

BMV:STP N;  DB:S9H;  NYSE:STP;  XTRA:S9H

As if it was not complicated enough, some time firms have two or three
identifiers for the NYSE stock exchange because they are listed with
one or more subsidiaries. In such cases, I would like to retrieve the
main identifier only, that is the one with the shortest lentgh. For
instance, in example 2 I would need to retrieve only "C".

Example 2:

BASE:C;  BAYB:C;  BMV:C *;  BST:TRVC;  BVL:C;  DB:TRVC;  NYSE:C.PRH;
NYSE:C;  NYSE:C.PRI;  SOMA:CTGP11B;  TSE:8710;  XTRA:TRV


Thanks in advance
Best regards
Ghislaine
*
*   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