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

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

Sorting the sample based on quantiles

Postby tika_chiko » Sun Jan 20, 2019 9:24 am

Please help me. I have a variable, let's say the name of the variable is 'y'
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.


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

Re: Sorting the sample based on quantiles

Postby EViews Matt » Tue Jan 22, 2019 10:15 am

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)

Return to “Data Manipulation”

Who is online

Users browsing this forum: No registered users and 13 guests