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

st: Re: small problem with return macro


From   "Michael Blasnik" <michael.blasnik@verizon.net>
To   <statalist@hsphsun2.harvard.edu>
Subject   st: Re: small problem with return macro
Date   Sat, 10 Apr 2004 09:56:41 -0400

The problem is caused by your use of the equal sign to assign it's value to
jb.  When you use an equals sign, Stata evaluates the string expression and
that's where you might get hit by limits (80 for regular Stata and 244 for
Stata/SE).  You apparently tried to copy the value by removing the eqauls
sign, but that just copies the characters r(mac) because you haven't told
Stata that it can be treated as a local macro.  Instead you need to copy the
contents of the macro and be sure that Stata knows it's a macro, for
example:

local jb "`r(mac)'"

Michael Blasnik
michael.blasnik@verizon.net


----- Original Message ----- 
From: "Jean-Benoit Hardouin" <jean-benoit.hardouin@neuf.fr>
To: <statalist@hsphsun2.harvard.edu>
Sent: Saturday, April 10, 2004 5:29 AM
Subject: st: small problem with return macro


> 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)?
>
> Thank you for your response
>
> -- 
>
****************************************************************************
*
> Jean-Benoit Hardouin
> 37 rue Arrachart
> 41000 Blois
> tél : 02 54 45 39 75
> email : jean-benoit.hardouin@neuf.fr
>
****************************************************************************
*


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