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

st: RE: small problem with return macro


From   "Nick Cox" <[email protected]>
To   <[email protected]>
Subject   st: RE: small problem with return macro
Date   Mon, 12 Apr 2004 18:00:25 +0100

Others noted the main difficulty. 

The example here may not be the real problem. Even if it isn't, 
the alternative solution of generating the contents
of such a list by a loop is worth noting. 

forval i = 1/50 { 
	local list "`list' `: di %02.0f `i'"
} 

That is, the little twist here of leading zeros is soluble 
by an in-line format. 

Nick 
[email protected] 

Jean-Benoit Hardouin
> 
> I have a small problem to use macros in the return command of 
> a program.
> 
> See the following program :
> 
> program define pgmmac, rclass
> local essai 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 
> 17 18 19 20 21 
> 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 
> 42 43 44 45 46 
> 47 48 49 50
> return local mac `essai'
> end
> 
> then type
> . pgmmac
> . return list
> macros:
>       r(mac) : "01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 
> 16 17 18 19 20 
> 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 
> 41 42 43 44 45 
> 46 47 48 49 50"
> 
> It's OK.
> 
> But if I want to save this macro r(mac) in an other macro I 
> have a problem 
> (limit to 80 characters) :
> 
> . local jb=r(mac)
> 
> . di "`jb'"
> 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 
> 21 22 23 24 25 
> 26 2
> 
> . local jb r(mac)
> 
> . di "`jb'"
> r(mac)
> 
> How solve this problem and to save all the characters of the 
> macro r(mac)?

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