Bookmark and Share

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


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

Re: st: RE : st: RE : st: RE : st: Do-file no result, command line OK


From   Robert Picard <[email protected]>
To   [email protected]
Subject   Re: st: RE : st: RE : st: RE : st: Do-file no result, command line OK
Date   Tue, 29 Mar 2011 09:55:58 -0400

Your problem is due to the fact that:

replace `var'_3= subinword(`var', "Chev", "", .)

uses the make variable as the source string for -subinword()-. You are
then reintroducing the dots.

Robert

On Tue, Mar 29, 2011 at 9:35 AM,  <[email protected]> wrote:
> I reproduce below two do-files which are similar to mine. The first one works fine, we get rid of the dot. However, the second one, which differs from the 1st one just because a command line has been added, doesn't work any more. This the thing I do not understand.
>
> *** Option 1
> sysuse auto
> global variables make                   // I have two variables in the original do-file
> foreach var in $variables {
> gen `var'_2 = subinstr(`var', " ", "", .)
> replace `var'_2= subinstr(`var', ".", "", .)
> }
>
>
> **** Option 2
> global variables make                   // I have two variables in the original do-file
> foreach var in $variables {
> gen `var'_3 = subinstr(`var', " ", "", .)
> replace `var'_3= subinstr(`var', ".", "", .)
> replace `var'_3= subinword(`var', "Chev", "", .)
> }
> browse
> ************
>
> Best,
>
> Xavier
>
> -------- Message d'origine--------
> De: [email protected] de la part de Nick Cox
> Date: mar. 29/03/2011 14:20
> À: [email protected]
> Objet : Re: st: RE : st: RE : st: Do-file no result, command line OK
>
> That does not make sense.
>
> ... if variable == "."
>
> can't be satisfied by values such as "BP P.L.C." as they are not equal to ".".
>
> Either you mean something else, or your copy of Stata is hopelessly corrupted.
>
> Nick
>
> On Tue, Mar 29, 2011 at 2:11 PM,  <[email protected]> wrote:
>
>> Unfortunately not. - browse if variable=="." - gives observations such as:
>> BP P.L.C.
>> However, once I copy and past the line in the command line instead of running the dofile, I get:
>> BP PLC
> *
> *   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/
>
>
> Please access the attached hyperlink for an important electronic communications disclaimer: http://lse.ac.uk/emailDisclaimer

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index