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

From |
"Nick Cox" <n.j.cox@durham.ac.uk> |

To |
<statalist@hsphsun2.harvard.edu> |

Subject |
RE: st: Re: saving memory local vs usual variable |

Date |
Fri, 3 Oct 2008 19:50:46 +0100 |

I think that's good advice for saving the mode(s) somehow. For reporting modes, see also -modes- from SJ. Also, -egen-'s -nummode()- option is for selecting from tied modes, not for selecting secondary or other modes. Thus, if values 1, 2, 3 occur equally frequently, so that all are candidates for mode, -nummode(2)- will select 2. But if only one mode exists, -nummode(2)- does not select the next most common value. Nick n.j.cox@durham.ac.uk Nick Winter Somewhere along the way there was a question about how to retrieve the mode, "second mode," "third mode" and so on. (I, too, am not sure if that is standard usage...) The easiest way I see to get there is: . sysuse auto . tab rep78, matcell(cell) matrow(row) sort The -sort- option tells Stata to sort the tabulation by frequency (highest to lowest). The -matrow(row)- option puts the values of rep78 in a matrix called 'row', and the -matcell(cell)- puts the actual frequencies in a matrix called 'cell.' So the modal value is . di row[1,1] The "second modal" value is . di row[2,1] and so on. Ashim Kapoor wrote: > Yes I see that. Quite clever. BUT what if it is something which is NOT > generated by a summary statistic . Like say the 2nd mode ( assuming a > variable has 2 modes). Can I directly store it into a local variable ? > On Fri, Oct 3, 2008 at 9:29 PM, Martin Weiss <martin.weiss1@gmx.de> wrote: >> As we said this morning: >> >> su age,mean >> loc lj=r(max) > ----- Original Message ----- From: "Ashim Kapoor" <ashimkapoor@gmail.com> >>> I have a question. Suppose I have a variable say - > age. Now I can do >>> egen j=max(age). Then I will have the max value of age in ONE >>> VARIABLE! Horrible waste of memory. I try to do local lj=max(age) and >>> that does not work. How can I conserve memory ? Is there something >>> basic which I have missed ? >>> >>> Thank you, >>> Ashim. >>> >>> PS : I do understand that I can do egen j = max (age ) and then say >>> local lj=j[1] and then -do drop j - but is there a better way ? * * 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/

**References**:**st: saving memory local vs usual variable***From:*"Ashim Kapoor" <ashimkapoor@gmail.com>

**st: Re: saving memory local vs usual variable***From:*"Martin Weiss" <martin.weiss1@gmx.de>

**Re: st: Re: saving memory local vs usual variable***From:*"Ashim Kapoor" <ashimkapoor@gmail.com>

**Re: st: Re: saving memory local vs usual variable***From:*Nick Winter <nwinter@virginia.edu>

- Prev by Date:
**st: propagating values within same name for the following 11 months** - Next by Date:
**st: estout with 2sls** - Previous by thread:
**Re: st: Re: saving memory local vs usual variable** - Next by thread:
**Re: st: Re: saving memory local vs usual variable** - Index(es):

© Copyright 1996–2016 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |