Statalist


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

Re: st: Re: Changing Prefix of Variable Name


From   Eric Booth <[email protected]>
To   [email protected]
Subject   Re: st: Re: Changing Prefix of Variable Name
Date   Mon, 2 Nov 2009 06:33:24 -0600

If Elisabeth really wants to change a prefix on the observations in a variable (not the variable name itself using -rensfix-), she can use - subinstr()- or -regexm()- for more complex substitutions, e.g.,

***
clear
input str10 var1
alpha
beta
delta
apple
arch
bean
aaaaaa
end

//change starting "a" only
gen pos = strpos(var1, "a")
replace var1 = subinstr(var1, "a", "1", 1) if pos==1
drop pos
*****

Eric



__
Eric A. Booth
Public Policy Research Institute
Texas A&M University
[email protected]
Office: +979.845.6754




On Nov 2, 2009, at 6:16 AM, E. Paul Wileyto wrote:

Search Stata help:

search rensfix, all

It's a user-written command that is very useful for changing prefixes and suffixes.



Elisabeth Müller wrote:
Hello,

does anybody know how to change the prefix of an observation (not variable)? E.g. if I want to change the observation "alpha" into "1lpha"?

Thanks


--
E. Paul Wileyto, Ph.D.
Assistant Professor of Biostatistics
Tobacco Use Research Center
School of Medicine, U. of Pennsylvania
3535 Market Street, Suite 4100
Philadelphia, PA  19104-3309

215-746-7147
Fax: 215-746-7140
[email protected]
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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