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: Loop question


From   Nikolaos Pandis <[email protected]>
To   "[email protected]" <[email protected]>
Subject   Re: st: Loop question
Date   Fri, 8 Feb 2013 22:24:04 -0800 (PST)

It worked!
Many thanks,
Nick
  

----- Original Message -----
From: Cory Smith <[email protected]>
To: [email protected]
Cc: 
Sent: Saturday, February 9, 2013 8:01 AM
Subject: Re: st: Loop question

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 <[email protected]> wrote:
> Hi to all,
>
> 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
>
> Thank you
>
> Nick
>
> *
> *   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/
*
*   For searches and help try:
*  http://www.stata.com/help.cgi?searchhttp://www.stata.com/support/faqs/resources/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/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index