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: Dividing data into quintiles


From   Clarice Martins <[email protected]>
To   [email protected]
Subject   Re: st: Dividing data into quintiles
Date   Mon, 28 Oct 2013 18:58:20 -0200

Sergiy,

Great points, thanks!

I was actually having trouble with this: 

> but, please post the example that exhibits exactly all the features
> that one would be looking forwards too - if you say you have 151
> periods of formation - make sure you post at least 2, better more, if
> there is irrelevant information - drop it right away not to confuse.
> Often times rather than anonymizing your data it is simpler to rename
> variables in nlsw88.

My data need not be anonymous, I just don't know how to post it more completely without getting into long emails and typing everything. A couple of times, I tried to attach the .dta file and then realized it is not permitted (i guess). So, should I just type a bigger set of data next time?


> 1) if you need only observations of type "formation" (and in your
> description it seems like this holds) then drop everything else to
> simplify things.

I believe I cannot drop other return types (rtype) because after dividing quintiles , I will need to pick up rtype=="buysell", from the co_id that are within the 1st and 5th quintile. so, i believe all the data must be there. Is this assumption correct?


Thank you for all your comments.... learning my ways with every input.



On Oct 28, 2013, at 5:02 PM, Sergiy Radyakin wrote:

> Clarice,
> 1) if you need only observations of type "formation" (and in your
> description it seems like this holds) then drop everything else to
> simplify things.
> 2) In the example data, you have constant returns 0.01 no matter what,
> I hope it is not in your real data, otherwise no quintiles, and also
> the group is extremely small - 3 obs only.
> 3) In your example all formations occur in one month, so not possible
> to test any code without actually creating a completely new example
> specifically for this.
> 
> Something like this would get you started:
> do http://radyakin.org/statalist/2013102801/formation.do
> 
> but, please post the example that exhibits exactly all the features
> that one would be looking forwards too - if you say you have 151
> periods of formation - make sure you post at least 2, better more, if
> there is irrelevant information - drop it right away not to confuse.
> Often times rather than anonymizing your data it is simpler to rename
> variables in nlsw88.
> 
> Best, Sergiy Radyakin
> 
> 
> On Mon, Oct 28, 2013 at 2:39 PM, Clarice Martins
> <[email protected]> wrote:
>> Dear group,
>> 
>> I need to select a sub-group of my dataset and cut it into quintiles, in order to proceed with calculations with top and bottom quintile.
>> 
>> - I use Stata 12.1 (for Mac)
>> 
>> - my data looks like this (now, after considerations from the group, thank you!)
>> 
>> co_id ticker rtype      yrmonth return
>> 1 ABCB formation jun2000 0.01
>> 1 ABCB buysell jul2000 0.01
>> 1 ABCB holding ago2000 0.01
>> 2 AEDU formation jun2000 0.01
>> 2 AEDU buysell jul2000 0.01
>> 2 AEDU holding ago2000 0.01
>> 3 AMBV formation jun2000 0.01
>> 3 AMBV buysell jul2000 0.01
>> 3 AMBV holding ago2000 0.01
>> 
>> - i tryed both -egen cut- and -xtile-
>> 
>> egen quintile = cut(return) if rtype=="formation", group(5)
>> 
>> xtile quintile=return if rtype=="formation", n(5)
>> 
>> - when I use -if rtype=="formation"- both commands work fine!
>> 
>> - But, I need to select all observations rtype=="formation"  AND yrmonth=="jun2000", then cut this subgroup into quintiles
>> 
>> - Then, I need to proceed with this filter/select and cut, for every yrmonth (151 periods) on my data set
>> 
>> Any suggestions?
>> 
>> Thank you very much!
>> 
>> Clarice
>> 
>> 
>> 
>> *
>> *   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