Bookmark and Share

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

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

st: Referencing individual elements of (local) macros

From   miros lav <>
Subject   st: Referencing individual elements of (local) macros
Date   Thu, 2 Dec 2010 22:03:57 +0100

Dear Statalisters,

I am wondering whether it is possible to reference the individual
elements of a (local) macro by a number. For example, if I have the
local macro x "var1 var2 var3". How would something like reg y `x'[3]

Long explanation:

I would like to estimate a number of models with different dependent
and independent variables. The control variable varies with the
dependent variable. I would like to use some kind of loop structure
(since I want to do a lot of estimations). so, I have defined two
macros. Lets say that they each have three elements.

local depvars " depvar1 depvar2 depvar3"
local controlvars " controlvar1 controlvar2 controlvar3"

I would like to do something like that

foreach c of local depvar{
reg `c' `controlvars'[i]

Thanks for your help!

*   For searches and help try:

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