Friday, March 17, 2006

st: Re: Using local variables in the name of a global variable

You need to reference the global macro name using brackets to make it clear to Stata what you want:

di "${gooddaysY`y'M`m'}"

Michael Blasnik

----- Original Message ----- "Danielle H. Ferry" <dferry@nber.org> wrote: > > I want to define a global variable whose name contains 2 local variables > (b/c > I am creating it w/in nested loops over year & month): > > forval y = 1980(1)2006 { > forval m = 1(1)12 { > global gooddaysY`y'M`m' = "stuff" > di "$gooddaysY`y'M`m'" > } > } > > Suppose we are in the y = 1980 & m = 1 loop. Then the result of > the -display- > is: 1980M1. I am guessing this has something to do w/ the quotes. But I > don't > know how to fix it. Any ideas? > > Thanks, > Danielle Ferry

* * 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/


Tag:


Links to this post:

Create a Link



<< Home

This page is powered by Blogger. Isn't yours?