Statalist


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

Re: st: Re: saving memory local vs usual variable


From   "Eva Poen" <[email protected]>
To   [email protected]
Subject   Re: st: Re: saving memory local vs usual variable
Date   Fri, 3 Oct 2008 18:10:14 +0100

-egen, max()- allowes -by-. I.e. it can do more than just create a
constant. A local can only hold one number/string.

You are right about the single variable in -egen, max()-. -egen,
rowmax()- does the same for a list of variables.

Generally, you will just have to get used to the fact that -egen-
functions are only available within egen. Most of what you want to do
can be done in two lines (as opposed to one line as you are
proposing), so it's really not too much extra effort.

Btw, I second Maarten's recommendation of the NetCourses. They are excellent.

Eva

2008/10/3 Ashim Kapoor <[email protected]>:
> On 2nd thought.
>
> egen j=max(x) DOES NOT take more than one variable.
>
> It is gen which can do the max of 2 or more variables.
>
> So since egen returns a variable with ONE constant value, it would
> seem that it should be allowed to be stored in a scalar / local macro.
>
> Thank you,
> Ashim.
>
> On Fri, Oct 3, 2008 at 10:26 PM, Ashim Kapoor <[email protected]> wrote:
>> Ahh I see what you are saying. For multiple variables it won't work. I
>> usually use it to find the max of ONE variable. I guess that confused
>> me.
>>
>> Thank you,
>> Ashim.
>>
>> On Fri, Oct 3, 2008 at 10:21 PM, Eva Poen <[email protected]> wrote:
>>> 2008/10/3 Ashim Kapoor <[email protected]>:
>>>>
>>>> And I am still puzzled as to why someone would not allow us to set
>>>> local  j=max(list)
>>>> cos that seems intuitive.
>>>
>>> If the list includes variable names, how is Stata supposed to know
>>> which observation's maximum you mean? -egen- is meant to work with
>>> variables. -egen- functions are not available outside -egen.
>>>
>>> On the other hand, there are Stata functions (-help functions-) which
>>> will work in general expressions. Therefore,
>>>
>>> local j = max(4, 92, -35, 399, 0)
>>>
>>> will correctly store 399 in local macro j.
>>>
>>> Eva
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   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