Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

st: How to reference tempvars across ML programs?


From   "Stephen P. Jenkins" <stephenj@essex.ac.uk>
To   statalist@hsphsun2.harvard.edu
Subject   st: How to reference tempvars across ML programs?
Date   Thu, 10 Oct 2002 16:47:34 +0100 (GMT Daylight Time)

ML programs written in ado file form comprise a main program and 
another program (or programs) called each iteration to evaluate the 
likelihood. Advice please about how to reference in the likelihood 
evaluation program(s), temporary variables that are created in the main 
program.

More details: 
In myp1.ado I currently have code like
	generate z`i'`d' = uniform()
generated in a loop, where `i' = 1,...,$M, and `d' = 1,...,$D (and both 
$M, $D are user-defined).  The -ml- command in this file calls 
myp1_ll.ado in which I do calculations referring to each variable 
z`i'`d', again within a loop over `i' and `d'.

I can make the program work in this way, but note that the "z" prefix 
means that I am generating permanent variables with a specific name 
(a Bad Thing as far as programming is concerned).
How can I make these indexed variables temporary but still refer to 
them correctly?
I've played around with using -tempvar- commands within myp1.ado, but I 
don't seem able to refer to these (suitably indexed) in myp1_ll.ado. 
(Note too Manual [P] macro entry, p. 133, that warns that one cannot 
suffix temporary variables with additional characters and use them.)
Another idea was to use global macros to hold the variable names 
created, but again I couldn't get this to work. 

thanks for any advice and suggestions.
Stephen
----------------------
Professor Stephen P. Jenkins <stephenj@essex.ac.uk>
Institute for Social and Economic Research (ISER)
University of Essex, Colchester, CO4 3SQ, UK
Tel: +44 (0)1206 873374. Fax: +44 (0)1206 873151.
http://www.iser.essex.ac.uk

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