Dear Clyde Schechter , in this thread (https://www.statalist.org/forums/for...61#post1701361) you have stated that
I am also used to use locals and I think the reason is quite obvious. But in recent projects I started to use globals more often. After your quote I think about rethinking my approach.
So at the moment I see two use cases for globals:
1. Setting up paths at start of Stata (a do-file called within profile.do) to be able call the paths in a shorthanded way (and to share do-files)
2. Setting up (graph) options at the beginning of a do-file to be able to test various alternatives or iterations without rerunning locals again and again
Both practices are explained by Worldbanks' DIME. Use case 1 at https://dimewiki.worldbank.org/Stata...ces#File_Paths and use case 2 at https://dimewiki.worldbank.org/Stata..._Visualization
I think these use caes show good and legitimate reasons to use globals, or am I wrong? Given your quote I wonder whether you see alternative, better approaches to use globals in these use cases.
Marc
"That said, there is no reason to use a global macro here. Local macros area safer programming practice and should always be used in preference to global macros unless it is simply not possible. (I have been using Stata since 1994 on a more or less daily basis and in all that time I have only once encountered the need to use a global macro--it's really very rare.)"
So at the moment I see two use cases for globals:
1. Setting up paths at start of Stata (a do-file called within profile.do) to be able call the paths in a shorthanded way (and to share do-files)
2. Setting up (graph) options at the beginning of a do-file to be able to test various alternatives or iterations without rerunning locals again and again
Both practices are explained by Worldbanks' DIME. Use case 1 at https://dimewiki.worldbank.org/Stata...ces#File_Paths and use case 2 at https://dimewiki.worldbank.org/Stata..._Visualization
I think these use caes show good and legitimate reasons to use globals, or am I wrong? Given your quote I wonder whether you see alternative, better approaches to use globals in these use cases.
Marc
Comment