Hi

I would like to create a string variable that copies all characters from another string variable up to specific characters:

Here is a sample of the data:
Code:
MarketName
1414 Degrees Limited CONS 285@31 19M13:733751~1072
1414 Degrees Limited CONS 286@31.5 19M13:733745~875
8IP Emerging Companies Limited CONS 125@71 19M13:733746~2001
8IP Emerging Companies Limited CONS 126@72 19M13:733746~1995
8common Limited CONS 1999@4.4 19M13:733745~532
8common Limited CONS 2000@4.5 19M13:733745~531
9 Spokes International Limited CONS 937500@1.6 19M13:774955~1983
9 Spokes International Limited CONS 937500@1.600 Z8750-BL150442
9 Spokes International Limited Rights Issue - Taken Up CONS 937500@1.600 Z8750-BL147287
9 Spokes International Limited Rights Issue - Taken Up CONS 937500@1.600 Z8750-BL150434
I am trying to generate another string variables up to the characters " CONS ". For the given data sample, that would be:
Code:
MarketName
1414 Degrees Limited
1414 Degrees Limited
8IP Emerging Companies Limited
8IP Emerging Companies Limited
8common Limited
8common Limited
9 Spokes International Limited
9 Spokes International Limited
9 Spokes International Limited Rights Issue - Taken Up
9 Spokes International Limited Rights Issue - Taken Up
I have tried using a combination of the following, but I could not reach my goal:
gen newvar = substr(MarketName, strpos(MarketName, ":") + 1, .) Please help. Thanks!