Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: retrieving a three-letter word from a string variable


From   "Dev Vencappa" <[email protected]>
To   <[email protected]>
Subject   st: retrieving a three-letter word from a string variable
Date   Fri, 28 May 2004 15:52:19 +0100

Dear users,

 I have a dataset that contains several string variables. Suppose one string variable contains the following values in one of the observations:

CMLST(HMV)

Another string variable contains :

COMSTL  GTRI(HMV)

I want stata to create a new variable that retrieves only the three-letter word "HMV" from the string variable. I understand that the substr command does that but because the starting point of the word HMV is not the same for every variable , it would be difficult to identify the correct starting position to read the string and retrieve the first three letters HMV. 
Can somebody help please? I have tried the other string commands but could not understand one that does what I want.

Many thanks
Dev



This message has been scanned but we cannot guarantee that it and any
attachments are free from viruses or other damaging content: you are
advised to perform your own checks.  Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.


*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index