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

Re: st: Replace one variable when other variable contains certain characters


From   Rafal Raciborski <[email protected]>
To   [email protected]
Subject   Re: st: Replace one variable when other variable contains certain characters
Date   Sun, 18 Dec 2005 23:05:12 -0500

replace X = "m12" if regexm(Y, "Dec")
etc.

rafal


Quoting "FUKUGAWA, N." <[email protected]>:

Dear all,
Suppose we have string variable Y, and we would like to replace
variable X when variable Y contains certain characters such as
"Dec".
In other words, we want to write;
replace X="m12" if Y (contains "Dec")
replace X="m11" if Y (contains "Nov")
replace X="m10" if Y (contains "Oct") .
How can I write the latter part of command?
Please note Y can be Dec123abc, 456Novpqr, and zzz789Oct.

Thank you in advance.
--
FUKUGAWA Nobuya, Ph.D.
[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/



================
Rafal Raciborski
Graduate student
Department of Political Science
Emory University
301 Tarbutton Hall
1555 Dickey Drive Atlanta, GA 30322
404-378-9826 (home)
[email protected]
http://www.roofoos.net/


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