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

RE: st: question about gettoken and file


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   RE: st: question about gettoken and file
Date   Wed, 26 Mar 2003 12:54:18 -0000

Edwin Leuven
> 
> On Tue Mar 25 2003 16:57, Jeff Pitblado, Stata Corp. wrote:
> > The following is a log from a do-file I wrote.  The point 
> here is that
> > macro expansion characters (` and $) need to be escaped 
> to prevent the
> > macros from being expanded.  Thus if Edwin wants to write 
> "di `i'" to a
> > file using -file-, he must use "di \`i'".
> 
> thanks. i was wondering (and trying) whether something like 
> the following is 
> possible with an ado:
> 
> pforeach v1 of var x1-x3 \ v2 of var y1-y3 \ i in 1 2 3: g 
> z`i' = `v1'*`v2'

Not with an ado. One explanation of the issues 
is at 

http://www.stata.com/support/faqs/lang/macros.html

They key principle is the substitution first rule: 
Stata will replace all macro names by their current 
contents (possibly, nothing) before passing the remainder
of the line to the ado. 

Nick 
[email protected] 


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