Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down on April 23, and its replacement, statalist.org is already up and running.


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

Re: st: replace part of observations in a string variable


From   Muhammad Anees <anees@aneconomist.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: replace part of observations in a string variable
Date   Wed, 17 Oct 2012 15:08:20 +0500

Hi,

This can be for you.

http://www.stata.com/statalist/archive/2011-06/msg00393.html

HTH
Anees

On Wed, Oct 17, 2012 at 3:02 PM, Kamarul Imran <kim4597@gmail.com> wrote:
> Hi all,
>
> I want to replace part of observations in the string variable to
> missing values. For example, I want to replace "Pasir Mas" to either
> "." or " " from a string variable named as "new2"
>
> ------------------------------------
> new2
> ------------------------------------
> Tumpat
> Tumpat
> Kota Bharu
> Kota Bharu
> Pasir Mas
> Kota Bharu
> Kota Bharu
> --------------------------------------
>
> what I did was:
>
> . replace addnew2=" " if addnew2 == "Pasir Mas"
> (0 real changes made)
>
> Observation "Pasir Mas" was not replaced by " " . What have I done
> wrong? What is the better way of working with string variable?
> Appreciate everyone's' time in responding to this.
>
> Regards
>
> Kamarul
> UK
> *
> *   For searches and help try:
> *   http://www.stata.com/help.cgi?search
> *   http://www.stata.com/support/faqs/resources/statalist-faq/
> *   http://www.ats.ucla.edu/stat/stata/



-- 

Best
---------------------------
Muhammad Anees
Assistant Professor/Programme Coordinator
COMSATS Institute of Information Technology
Attock 43600, Pakistan
http://www.aneconomist.com
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index