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

# RE: st: AW: creating subsamples in panel data

 From "Bontempo, Daniel E" To Subject RE: st: AW: creating subsamples in panel data Date Fri, 6 Aug 2010 13:42:52 -0500

```You need to say "if rank==1/1000"

-----Original Message-----
From: owner-statalist@hsphsun2.harvard.edu [mailto:owner-statalist@hsphsun2.harvard.edu] On Behalf Of David Kehrl
Sent: Friday, August 06, 2010 1:42 PM
To: statalist@hsphsun2.harvard.edu
Subject: Re: st: AW: creating subsamples in panel data

Thanks a lot for your help. I think I get the principle. But when i
try doing the regression
" xtreg credit assets repo" and try to add the "if rank=1/1000" e.g.
im getting syntax error.
what is the right way do the conditionary part?

Regards,
David

2010/8/6 Martin Weiss <martin.weiss1@gmx.de>:
>
> <>
>
> This is a dopey example that shows you valuable techniques in this area:
>
> *************
> clear*
> set obs 10
> gen byte bank=_n
>
> //expand to # of time periods
> expand 4
>
> //get time period
> bys bank: gen byte time=_n
>
> //xtset the thing
> xtset bank time
> gen assets =rnormal(1000000,200000)
>
> l, noo sepby(bank)
>
> //get average assets
> bys bank: egen avassets=mean(assets)
> egen tag=tag(bank)
> egen rank=rank(avassets) if tag
>
> gen x=rnormal()
>
> //regressions based on average assets
> reg avassets x if inrange(rank,1,4)
> reg avassets x if inrange(rank,5,7)
> reg avassets x if inrange(rank,8,10)
> *************
>
>
>
> HTH
> Martin
>
>
> -----Ursprüngliche Nachricht-----
> Von: owner-statalist@hsphsun2.harvard.edu
> [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von David Kehrl
> Gesendet: Freitag, 6. August 2010 18:00
> An: statalist@hsphsun2.harvard.edu
> Betreff: Re: st: AW: creating subsamples in panel data
>
> Yes i want to use the average asset size over the whole sample period.
> But my main problem is that once I have e.g. ranked the asset variabel
> i dont know who I can connect the ranking to the other variables
> without mixing  observations from different banks.
> For example i used collapse but the I only get the asset variabel in
> order and not the other ones.
> But obviously I need to order the whole dataset by asset size.
> But maybe I am just confused and missing the point?
>
> Thanks so much,
>
> David
>
> 2010/8/6 Martin Weiss <martin.weiss1@gmx.de>:
>>
>> <>
>>
>>
>> Some function in -help egen- will be the solution, I guess, e.g. the
>> -pctile- function, or -rank-. Do you want to base the decision on average
>> assets of the bank over the entire sample period, or on those in a
> specific
>> year?
>>
>>
>>
>> HTH
>> Martin
>>
>> -----Ursprüngliche Nachricht-----
>> Von: owner-statalist@hsphsun2.harvard.edu
>> [mailto:owner-statalist@hsphsun2.harvard.edu] Im Auftrag von David Kehrl
>> Gesendet: Freitag, 6. August 2010 17:43
>> An: statalist@hsphsun2.harvard.edu
>> Betreff: st: creating subsamples in panel data
>>
>> Hi,
>>
>> I have have a large panel dataset containing bank data. I have a time
>> variabel and a panel variable that identifies every bank uniquely.
>> Now I want to divide my data in three groups( by percentiles) by their
>> asset size  to run regression for each individual group.
>> I tried evey function I know about but nothing seems to work properly.
>> I would be extremely grateful for every help I can get on this.If you
>> wonder this is for my Bachelor Thesis and kind of new to STATA.
>>
>> Kindly,
>>
>> David Kehrl
>> *
>> *   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/
>>
>>
>> *
>> *   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/
>>
>
> *
> *   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/
>
>
> *
> *   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/
>

*
*   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/

*
*   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/
```