The data is a list of end of month stock prices, stock returns and begin of month ratios and size.
The purpose here is to make for each month quartiles depending on a certain variable (size) and making 4 portfolios,. Then once 4 portfolios are made each portfolio is resorted in 4 quantiles depending on another variable (BM). Thus in total this will give 16 portfolios (4x4). Then once thes portfolios made I would like to have 2spreadsheets in excel: 1spreadsheet for monthly equally-weighted returns (for the 16portfolios) and 1spreadsheet with size-weighted returns (for the 16portfolios).
The whole thing has to be done for 3 different files called 'up', 'down' and 'stationary'.