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

Re: st: editing words within a string variable


From   Michael McCulloch <[email protected]>
To   [email protected]
Subject   Re: st: editing words within a string variable
Date   Sat, 26 Feb 2005 18:07:21 -0800

Thank you Fred!

At 06:02 PM 2/26/2005, you wrote:
I don't think that there is a command that will do this.

help strfun shows the following functions, they are what you need

subinstr(s1,s2,s3,n) returns s1 where the first n occurrences in s1 of s2 have been replaced with s3. If n is missing (.), all occurrences are replaced.

subinword(s1,s2,s3,n) returns s1 where the first n occurrences in s1 of s2 as a word have been replaced with s3. A word is defined as a space-separated token; a token at the beginning or end of s also counts as being space-separated.

substr(s,n1,n2) returns the substring of s starting at n1 for a length of n2. If n1<0, the starting position is interpreted as distance from the end of the string. If n2 is missing (.), the remaining portion of the string is returned.

Fred Wolfe


At 07:41 PM 2/26/2005, you wrote:

Greetings Stata list members,
I have been unsuccessful searching the archives for commands (which will not require programming) that will do the following:

1. Edit words within a string variable that contains several words
2. Display this string variable with each word abbreviated to one or two letters.

Can anyone suggest a method?




Best wishes,
Michael


____________________________________

Michael McCulloch, LAc, MPH
Pine Street Clinic
124 Pine Street, San Anselmo, CA 94960-2674
tel 415.407.1357
fax 415.485.1065
email: [email protected]
web: www.pinest.org
www.pinestreetfoundation.org





*
* 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/

Fred Wolfe
National Data Bank for Rheumatic Diseases
Wichita, Kansas
Tel (316) 263-2125     Fax (316) 263-0761
[email protected]


*
*   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/

Best wishes,
Michael


____________________________________

Michael McCulloch, LAc, MPH
Pine Street Clinic
124 Pine Street, San Anselmo, CA 94960-2674
tel     415.407.1357
fax     415.485.1065
email:  [email protected]
web:    www.pinest.org
        www.pinestreetfoundation.org





*
*   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