Page 1 of 1

How to obtain cross section with max/min value of a series in a panel data set?

Posted: Mon Feb 03, 2020 4:26 am
by mamo
Dear Eviewers,

in a panel data work page, is there a simple approach to obtain the cross-section for which the value of a series takes a maximum (or minimum) across all cross-sections at a given date, or within a given sub-sample?

Best, Mamo

Re: How to obtain cross section with max/min value of a series in a panel data set?

Posted: Mon Feb 03, 2020 6:19 am
by mamo
I have found myself one solution to pick up the respective @crossids at each date which works as long as @maxsby(x, @date)/ @minby(x, @date) provide unique values (otherwise, only the first @crossid will be provided).
Any other suggestions are much welcome
Best, mamo

Code: Select all

' Show for each date @crossed for which series x is max
smpl @all if @maxsby(x, @date)=x
group gr @date @crossid
gr.sort(@date, @crossid)
show gr
' Alternatively: generate series indicating the @crossid which takes the max/min value of x in the respective date.
' indicator=(@maxsby(x, @date)=x)