Hello everyone,
I am using Stata 10.1. When I run the following commands from the command line I have no problem, but when I run them from a do file, the local macros are not created. What am I missing? Mary Ellen --------------------------------------------------- gllamm timeinj fup6 , i(partid) nrf(2) eqs(cons slope2) nip(2) ip(f) fam(poi) matrix a=e(b) local ll= e(ll) local k=e(k) gllamm timeinj fup6 , i(partid) nrf(2) eqs(cons slope2) nip(3) ip(f) from(a) /// fam(poi) gateaux(-10 10 30) lf0(`k' `ll') ----------------------------------------------------- * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/ |
<> "...are not created" could mean different things to different people... Throw in a -macro dir- after the two "local" lines, and see what you get. HTH Martin -----Ursprüngliche Nachricht----- Von: [hidden email] [mailto:[hidden email]] Im Auftrag von Mary E. Mackesy-Amiti Gesendet: Freitag, 9. April 2010 17:06 An: [hidden email] Betreff: st: local macro Hello everyone, I am using Stata 10.1. When I run the following commands from the command line I have no problem, but when I run them from a do file, the local macros are not created. What am I missing? Mary Ellen --------------------------------------------------- gllamm timeinj fup6 , i(partid) nrf(2) eqs(cons slope2) nip(2) ip(f) fam(poi) matrix a=e(b) local ll= e(ll) local k=e(k) gllamm timeinj fup6 , i(partid) nrf(2) eqs(cons slope2) nip(3) ip(f) from(a) /// fam(poi) gateaux(-10 10 30) lf0(`k' `ll') ----------------------------------------------------- * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/ |
In reply to this post by mmamiti
Note that "local" means precisely that. Local macros are local to the
program, do-file, do-file editor session, or interactive session in which they are defined and are not visible outside. Thus in fact your do-file will have created these macros; it is merely that they will not be visible within your interactive session. There are various solutions to this. One is to write a program. Another is to use globals. Yet another is to use -c_local-. In your case the best will be to avoid using locals altogether and pick up the e() results in your interactive session. The last has been called out "cutting out the middle macro", as the macro serves no real purpose in code like this. Nick [hidden email] Mary E. Mackesy-Amiti I am using Stata 10.1. When I run the following commands from the command line I have no problem, but when I run them from a do file, the local macros are not created. What am I missing? Mary Ellen --------------------------------------------------- gllamm timeinj fup6 , i(partid) nrf(2) eqs(cons slope2) nip(2) ip(f) fam(poi) matrix a=e(b) local ll= e(ll) local k=e(k) gllamm timeinj fup6 , i(partid) nrf(2) eqs(cons slope2) nip(3) ip(f) from(a) /// fam(poi) gateaux(-10 10 30) lf0(`k' `ll') ----------------------------------------------------- * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/ |
<> " Thus in fact your do-file will have created these macros;" So if Mary ran the _entire_ code between the two dashed lines in her post, the -macro-s should work as expected. Her choice of words "...a do file..." seems to suggest that this is indeed what is going on, so there should be no problem. If she interrupted execution, and then resumed for the second -gllamm- call, her -local-s would not be around... HTH Martin -----Ursprüngliche Nachricht----- Von: [hidden email] [mailto:[hidden email]] Im Auftrag von Nick Cox Gesendet: Freitag, 9. April 2010 17:13 An: [hidden email] Betreff: st: RE: local macro Note that "local" means precisely that. Local macros are local to the program, do-file, do-file editor session, or interactive session in which they are defined and are not visible outside. Thus in fact your do-file will have created these macros; it is merely that they will not be visible within your interactive session. There are various solutions to this. One is to write a program. Another is to use globals. Yet another is to use -c_local-. In your case the best will be to avoid using locals altogether and pick up the e() results in your interactive session. The last has been called out "cutting out the middle macro", as the macro serves no real purpose in code like this. Nick [hidden email] Mary E. Mackesy-Amiti I am using Stata 10.1. When I run the following commands from the command line I have no problem, but when I run them from a do file, the local macros are not created. What am I missing? Mary Ellen --------------------------------------------------- gllamm timeinj fup6 , i(partid) nrf(2) eqs(cons slope2) nip(2) ip(f) fam(poi) matrix a=e(b) local ll= e(ll) local k=e(k) gllamm timeinj fup6 , i(partid) nrf(2) eqs(cons slope2) nip(3) ip(f) from(a) /// fam(poi) gateaux(-10 10 30) lf0(`k' `ll') ----------------------------------------------------- * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/ * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/ |
Thank you, that solves it.
Martin Weiss wrote: > <> > > " Thus in fact your do-file will have created these macros;" > > > > So if Mary ran the _entire_ code between the two dashed lines in her post, > the -macro-s should work as expected. Her choice of words "...a do file..." > seems to suggest that this is indeed what is going on, so there should be no > problem. If she interrupted execution, and then resumed for the second > -gllamm- call, her -local-s would not be around... > > > > > HTH > Martin > > > -----Ursprüngliche Nachricht----- > Von: [hidden email] > [mailto:[hidden email]] Im Auftrag von Nick Cox > Gesendet: Freitag, 9. April 2010 17:13 > An: [hidden email] > Betreff: st: RE: local macro > > Note that "local" means precisely that. Local macros are local to the > program, do-file, do-file editor session, or interactive session in > which they are defined and are not visible outside. > > Thus in fact your do-file will have created these macros; it is merely > that they will not be visible within your interactive session. > > There are various solutions to this. One is to write a program. Another > is to use globals. Yet another is to use -c_local-. In your case the > best will be to avoid using locals altogether and pick up the e() > results in your interactive session. > > The last has been called out "cutting out the middle macro", as the > macro serves no real purpose in code like this. > > Nick > [hidden email] > > Mary E. Mackesy-Amiti > > I am using Stata 10.1. When I run the following commands from the > command line I have no problem, but when I run them from a do file, the > local macros are not created. What am I missing? > > Mary Ellen > > --------------------------------------------------- > gllamm timeinj fup6 , i(partid) nrf(2) eqs(cons slope2) nip(2) ip(f) > fam(poi) > matrix a=e(b) > local ll= e(ll) > local k=e(k) > > gllamm timeinj fup6 , i(partid) nrf(2) eqs(cons slope2) nip(3) ip(f) > from(a) /// > fam(poi) gateaux(-10 10 30) lf0(`k' `ll') > ----------------------------------------------------- > > > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/statalist/faq > * http://www.ats.ucla.edu/stat/stata/ > > > * > * For searches and help try: > * http://www.stata.com/help.cgi?search > * http://www.stata.com/support/statalist/faq > * http://www.ats.ucla.edu/stat/stata/ > > > -- Mary Ellen Mackesy-Amiti, Ph.D. Research Assistant Professor Community Outreach Intervention Projects (COIP) School of Public Health m/c 923 Division of Epidemiology and Biostatistics University of Illinois at Chicago ph. 312-355-4892 fax: 312-996-1450 * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/ |
In reply to this post by Martin Weiss-5
Quite. In effect I assumed that Mary Ellen did not mean precisely what
she said, because there would then have been no problem. Nick [hidden email] Martin Weiss " Thus in fact your do-file will have created these macros;" So if Mary ran the _entire_ code between the two dashed lines in her post, the -macro-s should work as expected. Her choice of words "...a do file..." seems to suggest that this is indeed what is going on, so there should be no problem. If she interrupted execution, and then resumed for the second -gllamm- call, her -local-s would not be around... Nick Cox Note that "local" means precisely that. Local macros are local to the program, do-file, do-file editor session, or interactive session in which they are defined and are not visible outside. Thus in fact your do-file will have created these macros; it is merely that they will not be visible within your interactive session. There are various solutions to this. One is to write a program. Another is to use globals. Yet another is to use -c_local-. In your case the best will be to avoid using locals altogether and pick up the e() results in your interactive session. The last has been called out "cutting out the middle macro", as the macro serves no real purpose in code like this. Mary E. Mackesy-Amiti I am using Stata 10.1. When I run the following commands from the command line I have no problem, but when I run them from a do file, the local macros are not created. What am I missing? --------------------------------------------------- gllamm timeinj fup6 , i(partid) nrf(2) eqs(cons slope2) nip(2) ip(f) fam(poi) matrix a=e(b) local ll= e(ll) local k=e(k) gllamm timeinj fup6 , i(partid) nrf(2) eqs(cons slope2) nip(3) ip(f) from(a) /// fam(poi) gateaux(-10 10 30) lf0(`k' `ll') ----------------------------------------------------- * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/ |
Free forum by Nabble | Edit this page |