Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: assigning the value of a function to a amcro


From   Nick Cox <njcoxstata@gmail.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: assigning the value of a function to a amcro
Date   Tue, 26 Feb 2013 07:39:21 +0000

I can't comment on your invisible case, but here is an example:

local bigger = max(7, 42)
di `bigger'

If your case involves one or more variables, then it can't be done,
except like this

tempvar bigger
gen `bigger' = max(42, somevar)

This is not really an exception, as the macro is holding the name of a
variable holding a maximum in each observation, not holding those
maximums (maxima).


Nick

On Tue, Feb 26, 2013 at 7:19 AM, James Bernard <jamesstatalist@gmail.com> wrote:

> I am trying to use the max()function and assign the outcome of the
> this to a a macro. But it seems impossible, no matter how I write it.
> I recall that, in general, macros can receive value of a function, but
> it just doesn't work in this case.
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index