Page 1 of 1

Sorting the sample based on quantiles

Posted: Sun Jan 20, 2019 9:24 am
by tika_chiko
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.

Thanks

Re: Sorting the sample based on quantiles

Posted: Tue Jan 22, 2019 10:15 am
by EViews Matt
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.