Statalist The Stata Listserver


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

RE: st: RE: local variable within a global macro?


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: RE: local variable within a global macro?
Date   Tue, 29 Aug 2006 16:47:01 +0100

The terminology is: 

long: global macros and local macros

short: globals and locals. 

Thanks for excellent thread closure here, 
an example for others to follow. I note
that the awkward numbering is the lesser 
evil. 

Nick 
n.j.cox@durham.ac.uk 

Nishant Dass
 
> Thank you very much for all your suggestions.  I must say,
> joining this list has been a good learning experience.  
> 
> For the sake of it, I tried all the solutions suggested and
> most worked. 
> 
> Nick's solution: Using ${X`p'} worked well.  (As regards
> the awkward numbering - in my present scenario, it's easier
> for me to use it as such; moreover, I was interested in
> knowing how to use local macros within global macros, and
> the current problem provided a good opportunity, so I kept
> the numbering as it is.)
> 
> Kris' solution: Defining my globals as locals instead (I
> would call them global macros and local macros but I am not
> sure; perhaps, Nick can clarify) and then writing `X`p''
> worked, too.
> 
> Alex's solution was right in principle but involved a small
> typo.  Instead of:
>       local globalname "X`np1'"
>       reg y`n' $X`globalname'
> it should be
>       local globalname "`X`np1''"
>       reg y`n' `globalname'
> 
> And finally, Prabhu was right, too - Kris' solution doesn't
> work if I retain the global macros. 
> 

*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/



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