## Sorting the sample based on quantiles

For questions regarding the import, export and manipulation of data in EViews, including graphing and basic statistics.

Moderators: EViews Gareth, EViews Jason, EViews Steve, EViews Moderator

tika_chiko
Posts: 4
Joined: Thu Dec 20, 2018 7:04 am

### Sorting the sample based on quantiles

I want to sort it based on quartiles in each year.
So I want to create another series, let's say series y_quan, that consists only the first 25% quartiles of variable y that has been sorted in each firm-year.
I noticed that we have @quantilesby formula. I have tried @quantilesby(y,@year,(0.25)) -> but this will give me the values of the firm-year quantiles. What I need is to create a series (y_quan) that consist the values of variable y, if it is in the 25%quartiles group.
I would like to also create another series for 25-50% quartiles group, 50-75% quartiles group, and 75% - 100% quartiles group.

Thanks

EViews Matt
EViews Developer
Posts: 430
Joined: Thu Apr 25, 2013 7:48 pm

### Re: Sorting the sample based on quantiles

A combination of @quartilesby and @recode can partition the data in the way you describe, for example,

Code: Select all

`series y_0_25 = @recode(y < @quantilesby(y, @year, .25), y, na)series y_25_50 = @recode(y >= @quantilesby(y, @year, .25) and y < @quantilesby(y, @year, .5), y, na)etc.`