Effacer les filtres
Effacer les filtres

merge datset one to many

2 vues (au cours des 30 derniers jours)
Qifan
Qifan le 29 Juil 2014
Commenté : Qifan le 29 Juil 2014
Help~
I have a panel data, for example:
A=[firm1_1970, firm1_1971,...firm1_1990, firm2_1970, firm2_1971,...firm2_1985,...,firm100_1995].
As you can see, the dataset has many years, and in each year there are observations of a number of firms.
Now I have another dataset which is the interest rate for each year, for example:
B=[r_1970, r_1971, r1972,..., r_1990].
I need to merge the two datset, but the join function seems not work because the 'Keys' (which is year) is not unique in A (the panel data). Is there any way to make such "one-to-many" merge? Many thanks.

Réponse acceptée

Azzi Abdelmalek
Azzi Abdelmalek le 29 Juil 2014
A={'firm1_1970', 'firm1_1971','firm1_1990', 'firm2_1970', 'firm2_1971','firm2_1985','firm100_1995'}
B=regexp(A,'(?<=_)\d+','match')
out=cellfun(@(x) strcat('r_',x{1}),B,'un',0)
  1 commentaire
Qifan
Qifan le 29 Juil 2014
Thanks, Azzi!
:)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Datafeed Toolbox dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by