Statalist


[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: RE: Efficient coding with -replace-


From   "Martin Weiss" <martin.weiss1@gmx.de>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: RE: Efficient coding with -replace-
Date   Sun, 5 Oct 2008 17:18:55 +0200

Only seven minutes from problem to solution... On second thoughts, though,
you might want to leave the -if- qualifier out of the -local- in case you
want to use the qualifier from a dialog box. The -if- is added automatically
when you enter something into the respective field in the dialog box so it
is probably better to omit the -if- in the -macro-. Otherwise there will be
two ifs, one from the -macro- the other constructed by the dialog...


HTH
Martin


-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu
[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Michael McCulloch
Sent: Sunday, October 05, 2008 5:04 PM
To: statalist@hsphsun2.harvard.edu
Subject: Re: st: RE: Efficient coding with -replace-

Thanks Martin, this is helpful.

>-replace- expects "oldvar =exp", so no, I do not think there is a more
>efficient way. Multiple instances of the same -if- qualifier always make it
>advisable to throw it into a -local-
>
>local mycond " if id==80"
>replace month = 1 `mycond'
>replace year =  1996 `mycond'
>replace failed= 1 `mycond'
>
>
>HTH
>Martin
>
>-----Original Message-----
>From: owner-statalist@hsphsun2.harvard.edu
>[mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Michael
McCulloch
>Sent: Sunday, October 05, 2008 4:57 PM
>To: Statalist
>Subject: st: Efficient coding with -replace-
>
>Greetings,
>As part of a data audit, I'm recording some changes in my project
>do-file. Would there be a more efficient way to code the following
>changes, all of which involve the same observation?
>
>replace month = 1 if id==80
>replace year =  1996 if id==80
>replace failed= 1 if id==80
>
>   Thank you kindly.
>--
>
>Best wishes,
>Michael McCulloch
>
>
>
>Pine Street Foundation
>124 Pine St., San Anselmo, CA 94960-2674
>Tel:	(415) 407-1357
>Fax:	(415) 485-1065
>mcculloch@pinestreetfoundation.org
>www.pinestreetfoundation.org
>*
>*   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/

*
*   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–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index