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]

From |
Nick Cox <njcoxstata@gmail.com> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
Re: st: Loop question |

Date |
Sat, 9 Feb 2013 15:51:36 +0000 |

Note also that using equals signs when not needed can bite you: SJ-8-4 pr0045 . . . . . . . . Stata tip 70: Beware the evaluating equal sign . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . N. J. Cox Q4/08 SJ 8(4):586--587 (no commands) tip explaining the pitfall of losing content in a macro because of limits on the length of string expressions Nick On Sat, Feb 9, 2013 at 3:35 PM, Cory Smith <corybsmith@gmail.com> wrote: > It's a stylistic choice. Personally, I think it's cleaner to declare > all special lists upfront, though I realize there are aspects of > Stata's structure which discourage this. On Sat, Feb 9, 2013 at 4:34 AM, Nick Cox <njcoxstata@gmail.com> wrote: >> Could also be >> >> foreach e in _icw _imp1w _imp2w _mw { >> reg post`e' i.appliance pre`e' >> } >> >> The local macro does no harm, but more direct code will work too. On Sat, Feb 9, 2013 at 6:01 AM, Cory Smith <corybsmith@gmail.com> wrote: >>> do something like: >>> >>> local ends = "_icw _imp1w _imp2w _imw" >>> >>> foreach e of local ends { >>> reg post`e' i.appliance pre`e' >>> } On Sat, Feb 9, 2013 at 12:54 AM, Nikolaos Pandis <npandis@yahoo.com> wrote: >>>> I am trying to do the following in Stata 12.1: >>>> ************************************************************ >>>> >>>> foreach myvarpre of varlist pre_icw pre_imp1w pre_ipm2w pre_imw { >>>> foreach myvarpost of varlist post_icw post_ipm1w post_ipm2w post_imw { >>>> reg `myvarpost' i.appliance `myvarpre', noheader >>>> } >>>> } >>>> ******************************************************************* >>>> How can I restrict in the regression and adjust only for the corresponding pre_* variable and not for all the variables in my list? >>>> >>>> I would like only to get only the following: >>>> >>>> reg post_icw i.appliance pre_icw >>>> reg post_imp1w i.appliance pre_imp1w >>>> reg post_imp2w i.appliance pre_imp2w >>>> reg post_imw i.appliance pre_imw * * 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/

**Follow-Ups**:**Re: st: Loop question***From:*Cory Smith <corybsmith@gmail.com>

**References**:**st: Loop question***From:*Nikolaos Pandis <npandis@yahoo.com>

**Re: st: Loop question***From:*Cory Smith <corybsmith@gmail.com>

**Re: st: Loop question***From:*Nick Cox <njcoxstata@gmail.com>

**Re: st: Loop question***From:*Cory Smith <corybsmith@gmail.com>

- Prev by Date:
**RE: st: sign of coefficients in a xtprobit** - Next by Date:
**Re: st: Loop question** - Previous by thread:
**Re: st: Loop question** - Next by thread:
**Re: st: Loop question** - Index(es):