Hi everyone,
I have a problem with settiung up a sample.
Let's assume I have a dated panelstructure with data for 7 years for 200 companies (revenue), which are located in 10 different countries. So there are about (not exactly) 20 companies located in each of the 10 countries. Now I am trying to look at statistics sorted by classification, i.e. sorted by country. How that works, I know. But, I would like to sample my datastructure in a way, that only the top five companies for each country are to be included in the statistics sorted by classification.
I seem not to be able to find the solution for this probably very simple problem. I'll be very grateful for help or advice. Thanks a lot in advance.
sampling and stats by classification
Moderators: EViews Gareth, EViews Steve, EViews Moderator, EViews Jason
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: sampling and stats by classification
Not easy. We'll need a bit more information. How is your workfile currently structured (i.e. what are the identifiers?). How are you defining "top 5 companies"?
-
neptunhiker
- Posts: 50
- Joined: Sat Oct 20, 2012 7:30 am
Re: sampling and stats by classification
Hi Gareth,
the identifier series could be the company names. The top 5 companies should be ranked by revenue, i.e. the 5 companies which have the highest revenue in each country are the top 5 for each country. To clarify things, I have attached a workfile with some sample data. I hope that helps to specify my question.
the identifier series could be the company names. The top 5 companies should be ranked by revenue, i.e. the 5 companies which have the highest revenue in each country are the top 5 for each country. To clarify things, I have attached a workfile with some sample data. I hope that helps to specify my question.
- Attachments
-
- sampling.WF1
- (61.32 KiB) Downloaded 320 times
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13604
- Joined: Tue Sep 16, 2008 5:38 pm
Re: sampling and stats by classification
Not the shortest, but the easiest to see what is going on:
Code: Select all
series first=0
series second=0
series third=0
series fourth=0
series fifth=0
smpl if revenue = @maxsby(revenue,country)
first = 1
smpl if revenue = @maxsby(revenue,country, "if first=0")
second = 1
smpl if revenue = @maxsby(revenue,country, "if first=0 and second=0")
third=1
smpl if revenue = @maxsby(revenue,country, "if first=0 and second=0 and third=0")
fourth=1
smpl if revenue = @maxsby(revenue,country, "if first=0 and second=0 and third=0 and fourth=0")
fifth=1
smpl if first=1 or second=1 or third=1 or fourth=1 or fifth=1
-
neptunhiker
- Posts: 50
- Joined: Sat Oct 20, 2012 7:30 am
Re: sampling and stats by classification
Thanks Gareth. Like always: quick and working answer. Maybe really not the shortest, but I can at least follow what's going on. If you had a solution which is more difficult to understand, but maybe also easier to apply to a bigger and more complex data set, then I'd be happy to see it as well. Thanks a lot.
Who is online
Users browsing this forum: No registered users and 2 guests
