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: add up variable / quantile
From
Nick Cox <[email protected]>
To
[email protected]
Subject
Re: st: add up variable / quantile
Date
Tue, 29 Mar 2011 08:53:10 +0100
On Tue, Mar 29, 2011 at 2:53 AM, Scharnigg, Stan (Stud. SBE) >
> A. I want to know the performance of retail investors. I have the account IDs, but the data
> is seperated in months. So I merged the files into stata. However, now I have multiple account IDs and Stata recognizes the performance for every month.
> I want to know what the total performance is for a single account ID.
>
> I will give a short example to make clear what I mean:
>
> accountID; gross_performance
> 1 -.1
> 1 .2
> 3 .1
> 3 .1
>
> desired outcome:
> AccountID; gross_performance
> 1 .1 (-.1+.2)
> 3 .2 (.1+.1)
Look at the help for -egen-. You want
egen total_gross = total(gross), by(accountID)
> B. Then, when I have the total performance. I want to divide it into quantiles (I want to get the top 25 percentile)
> If I use this command:
> "xtile quanvariable = Gross_performance, nquantiles(4)"
> I create a new variable and the top 25 percentile gets the number 4. However, how do I get an overview which account IDs are in the top 25 percentile?
> There will be around 2500 observations in the top 25 percentile, so therefore I was hoping that there is an option to get this information in an overview.
-list- ? -edit- ? Use -if- to select observations.
*
* 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/