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

# Re: st: Re: using categorical and continuous variables foreach loop for univaraite analysis

 From "Dimitriy V. Masterov" To Statalist Subject Re: st: Re: using categorical and continuous variables foreach loop for univaraite analysis Date Mon, 8 Jul 2013 16:05:52 -0700

```Michael,

Take a look at http://www.stata.com/support/faqs/programming/looping-over-parallel-lists/

If your variables have such convenient names, you can loop over i and
use logit i.cat`i' con`i'.

DVM

On Mon, Jul 8, 2013 at 3:51 PM, Michael Stewart
<michaelstewartresearch@gmail.com> wrote:
> Hello all,
>
> In my research project, I have a number of categorical predictors(cat1
> cat2 cat3 cat4 ) and continuous predictors(con1 con2 con3 con4) and
> during initial uni-variate analysis,  I am using two step process to
> evaluate for statistical significance.My code is a follows
>
> I use stata 12
>
> *********************MY CODE ********************
> foreach x of varlist cat1 cat2 cat3 cat4{
> logit outcome i.`x'
> }
>
> foreach x of varlist con1 con2 con3 con4{
> logit outcome `x'
> }
> ********************************************************
> Question:
>
> Is it possible to achieve this is one step i.e., use continuous and
> predictors as a single varlist but perform logistic regression still
> respecting the fact that  some are categorical variables and some are
> continuous variables
>
> --
> Yours Sincerely,
> Mike.
> *
> *   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?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/
```