Bookmark and Share

Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.


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

RE: st: how to exclude an observation when calculating the median of a group


From   Joe Canner <jcanner1@jhmi.edu>
To   "statalist@hsphsun2.harvard.edu" <statalist@hsphsun2.harvard.edu>
Subject   RE: st: how to exclude an observation when calculating the median of a group
Date   Mon, 7 Oct 2013 12:54:09 +0000

Nahla,

There was a question similar to this not long ago: http://www.stata.com/statalist/archive/2013-09/msg00744.html where several possible solutions were provided.  See if this helps and let us know if not.

Regards,
Joe Canner
Johns Hopkins University School of Medicine

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of Nahla Betelmal
Sent: Monday, October 07, 2013 7:38 AM
To: statalist@hsphsun2.harvard.edu
Subject: Re: st: how to exclude an observation when calculating the median of a group

Thank, I used this link before when I wanted to calculate the mean ( by subtracting each observation from the total) and dvide by n-1.
However, I could not figure out a way how to do it for the median!

Thanks again

Nahla


On 7 October 2013 12:16, Nick Cox <njcoxstata@gmail.com> wrote:
> This is a FAQ, itself frequently cited on this list.
>
> FAQ     . . Creating variables recording prop. of the other members of a group
>         . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .  N. J. Cox
>         4/05    How do I create variables summarizing for each
>                 individual properties of the other members of a
>                 group?
>                 http://www.stata.com/support/faqs/data-management/
>                 creating-variables-recording-properties/
>
> Nick
> njcoxstata@gmail.com
>
> On 7 October 2013 11:53, Nahla Betelmal <nahlaib@gmail.com> wrote:
>
>> I wonder how to exclude an observation when calculating the median of 
>> a group. In other words I want to calculate the median of variable X 
>> for firms in a specific year and specific industry, however, I want 
>> to exclude each firm observation when calculating the median.
>>
>> if there are 6 firms in a certain  industry/year. The median will be 
>> calculated based on the other 4 non missing firms observations
>>
>> Firm   VarX    Mediam_VarX
>> 1         10          based on firms 2,3,4,5 only
>> 2          8           based on firms 1,3,4,5 only
>> 3         12          based on firms 1,2,4,5 only
>> 4          14         based on firms 1,2,3,5 only
>> 5         10           based on firms 1,2,3,4 only
>> 6        missing            .
>>
>> I am stuck with the command for the part of excluding each firm 
>> observation, It would be great if someone can help in that.
> *
> *   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/
*
*   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/

*
*   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–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   Site index