Statalist The Stata Listserver

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

st: local variable within a global macro?

From   Nishant Dass <>
To   STATA Help <>
Subject   st: local variable within a global macro?
Date   Tue, 29 Aug 2006 05:54:43 -0700 (PDT)

Dear list-members, 

I have a small (or so it seems) problem with a loop (shown

I start by generating a few global macros:
global X2 "age2 weight2 height2"
global X3 "age3 weight3 height3"
global X11 "age11 weight11 height11"

Then I try to run the following set of regressions using a
forvalues n = 1/10 {
	local p = `n' + 1
	reg y`n' $X`p'

However, this isn't executed due to an error that says "2
invalid name" (i.e., it's referring to some problem in the
way I have used `p' in $X`p'.)

Could anyone please tell me what would be the correct way
to do this?  

Thank you very much for your help.


Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
*   For searches and help try:

© Copyright 1996–2015 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index