Statalist The Stata Listserver


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

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


From   "Danielle H. Ferry" <[email protected]>
To   [email protected]
Subject   st: Using local variables in the name of a global variable
Date   Fri, 17 Mar 2006 10:15:19 -0500

Hi,

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 

--
National Bureau of Economic Research <http://www.nber.org>

*
*   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–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index