MATLAB Answers

Resorting Rows in a Table with Panel Data

1 view (last 30 days)
I exported a table from Excel to Matlab. The file contains variables in panel data format, sorted by Country and Year. My time period stretches from 1990-2017. I had initially constructed the table from 1995-2017, and then at the end, I'd added the data from 1990-1994, again sorted by Country and Year (I did not need these time periods initially). So it is this way now:
Country 1 1995
Country 1 1996
Country 180 2017
Country 1 1990
Country 1 1991
Country 1 1992
Country 1 1993
Country 1 1994
Country 2 1990
Is it possible for me to rearrange the data in a way so that the entire dataset runs from 1990-2017, by Country and Year?

Accepted Answer

Adam Danz
Adam Danz on 14 Apr 2021
Edited: Adam Danz on 14 Apr 2021
See sortrows.
If there are any problems implementing that function, show us what you've got and we can help straighten it out.
Saunok Chakrabarty
Saunok Chakrabarty on 16 Apr 2021
Hi Adam,
Thanks a ton for this suggestion. I'm actually new to Matlab so this helps iron out my confusions.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!