如何排序表到五子集?
1视图(30天)
显示旧的评论
你好,
我有表与股票。现在我想根据它们的大小成子集。我的目标是创建5子集根据他们的大小,与每个人都持有20%的股票。Unfortunatley我不知道如何去做。市值的大小。的数据集的问题。
ID是代表不同的股票
年是oberved年(1962 - 2016)
sumMC每年每个股票的市值。
有人知道怎么做吗?
提前谢谢你
接受的答案
图像分析
2021年4月25日
只使用和线性索引
sortedCaps =排序(成分股市值,“提升”);
stocksPerGroup =长度(sortedCaps) / 5;
%提取股票进组# 1。
firstIndex = 1;
lastIndex =圆(stocksPerGroup);
group1 = sortedCaps (firstIndex: lastIndex);
%提取股票进组# 2。
firstIndex = lastIndex + 1;
lastIndex =圆(2 * stocksPerGroup);
group2 = sortedCaps (firstIndex: lastIndex);
%提取股票进组# 3。
firstIndex = lastIndex + 1;
lastIndex =圆(3 * stocksPerGroup);
group3 = sortedCaps (firstIndex: lastIndex);
%提取股票进组# 4。
firstIndex = lastIndex + 1;
lastIndex =圆(4 * stocksPerGroup);
group4 = sortedCaps (firstIndex: lastIndex);
%提取股票进组# 5。
firstIndex = lastIndex + 1;
lastIndex =长度(sortedCaps);
group5 = sortedCaps (firstIndex: lastIndex);