Statalist The Stata Listserver


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

RE: st: RE: fine tuning do files


From   "Nick Cox" <n.j.cox@durham.ac.uk>
To   <statalist@hsphsun2.harvard.edu>
Subject   RE: st: RE: fine tuning do files
Date   Mon, 30 Oct 2006 17:19:13 -0000

I imagine there are various ways in which you can
fool .do files into taking options, but seemingly 
always with some indirection. 

Here is one. 

Suppose you put the arguments you want into 
a global macro, say -args-. 

global args mpg weight, ytitle(hi there) 

Then at the top of the .do file, you set up 
a mapping so that local macro -0- picks up 
whatever is in that global. 

Know that -syntax- works on whatever is 
in local macro -0-. With a program this is
all done for you, typically at the start 
of the program, and invisibly. But occasionally 
it is useful to be able to exploit that fact. 

----------------------------- whatever.do 
local 0 $args 
syntax <whatever you want> 
...
-----------------------------

However, I can't see any advantage in 
doing this over following the straight 
and narrow path towards Stata programming, 
strict sense, that is, writing programs
not .do files. 

Nick 
n.j.cox@durham.ac.uk 

David Kantor
 
> I might add that do files can also have -syntax-, though I suppose 
> that -syntax- was not intended to be used that way. And you cannot 
> use options in this situation, as any options you write in the 
> command will be picked up as options to -do- (or -run-), and not 
> passed on to the do file.  So, you probably never would want to do 
> this, but it's interesting to know of the possibility.

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