Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at

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

st: Parsing words on allcaps

From   Matthew Kerby <[email protected]>
To   [email protected]
Subject   st: Parsing words on allcaps
Date   Sat, 17 Mar 2012 07:23:17 -0230

Dear Statalist

Perhaps somebody can advise on how to solve this problem.

I have a dataset which consists of a single string variable. The each observation consists of a sentence which in turn contains a name in all caps. I would like to create a new variable which contains only those words which appear in all caps. eg. in example below I would like to extract the name of the hockey player.

input str244 string  
"GRETZKY W. likes hamburgers"
"Hotdogs are preferred by LEMIEUX M."
"All things being equal, CROSBY S. will eat doughnuts"

I would like to end up with a string variable (player) which looks like the following:


Any help on how to parse a string variable on allcaps is greatly appreciated.

Matthew Kerby, PhD

Assistant Professor
Department of Political Science
Memorial University of Newfoundland
St. John's, Newfoundland, A1B 3X9, Canada

email: kerbym(at)
twitter: matthewkerby
Tel: (709) 864-3093
Fax: (709) 864-4000

This electronic communication is governed by the terms and conditions at

*   For searches and help try:

© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index