It's trivial to do any number of ways. But first, your date must be stored as a proper datetime. If it's stored as you show:
yourtable.DATE = datetime(yourtable.DATE, 'ConvertFrom', 'yyyymmdd');
Once that's done, the easiest way:
result = groupsummary(yourtable, {'PERMCO', 'DATE'}, {'none', 'month'}, 'sum')
It can also be done with findgroups and splitapply:
[monthid, actualmonth] = discretize(yourtable.DATE, 'month');
[group, PERMCO, monthnum] = findgroups(yourtable.PERMCO, monthid);
sum_VALUE = splitapply(@sum, yourtable.VALUE, group);
MONTH = actualmonth(monthnum);
result = table(PERMCO, MONTH, sum_VALUE);
It could also be done using rowfun or varfun.
Best Answer