Sorting last data of a group variables

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt

tmz
Posts: 6
Joined: Wed Aug 12, 2015 12:21 pm

Sorting last data of a group variables

Postby tmz » Wed Aug 12, 2015 12:42 pm

Hi,

I'm using Eviews 8.

I would like to create a bar graph with the last observation of 40 variables, but arranging the data values from maximum value to minimum value.

In addition, I would like the graph update itself with the new data each quarter and variable names to be linked to the observations of my bar graph.

What's the best way to accomplish this?

Thanks

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Re: Sorting last data of a group variables

Postby EViews Gareth » Wed Aug 12, 2015 1:37 pm

Set the sample to be the last observation, then convert the group into a vector (stom command), sort the vector (@sort), then make bar chart out of the vector.

There is no way to make it auto-update though. You'd have to re-run the .prg

tmz
Posts: 6
Joined: Wed Aug 12, 2015 12:21 pm

Re: Sorting last data of a group variables

Postby tmz » Wed Aug 12, 2015 2:14 pm

Hi,

Thanks for the quick answer.

I did what you recommended, but this method does not match the variable names with the observations in the bar chart.

Is it possible to do so?

Thanks

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13604
Joined: Tue Sep 16, 2008 5:38 pm

Re: Sorting last data of a group variables

Postby EViews Gareth » Wed Aug 12, 2015 2:39 pm

No, but here's a more complicated method:

Code: Select all

'make some data create u 10 for !i=1 to 5 series x!i=nrnd next group g x* 'make the graph. smpl @last @last stom(g, myvec) vector ranks = @ranks(myvec) %names = g.@members group g2 for !i=g.count to 1 step -1 for !j=1 to g.@count if ranks(!j)=!i then %name = @word(%names, !j) g2.add {%name} endif next next show g2.bar


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest