How to calculate Sums in a Panel Data framework using "For Loops"
Show older comments
The following table consists of Price Returns returns at different Dates:

Idea: For any given Date and Stock Ticker, if returns data of previous 12 time steps is available (cell is not NaN), sum those returns and stock them in a new table. Code:
% Take row by row
% Considering columns 2 to 279 look at each date point if returns data for previous 12 time steps (weeks) is available
for i=length(Tnew.Date)
for j=TNew.x1COVGY:end
if (TNew.x1COVGY:end = ~(‘NaN’))
% Sum those 12 entries and list the result in a new table. For example, A2AIM's value for 30-Oct will be the sum of values between 30-Oct and 14-Aug.
end
end
Thanks for your help!!
Accepted Answer
More Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!