I have a set of data like this:
id ---- name ---- beg_date ---- end_date --- type_1 --- type_2 ... type_n
01 ---- xxxx ---- 2015-10 ---- 2015-11 ----- Y -------- Y -------- N---
01 ---- xxxx ---- 2014-03 ---- 2015-09 ----- N -------- Y -------- N---
etc.
I want to make a table to count how many items of each type available for each month, so I wil do a loop from each the smallest oldest date to the most recent date by month. In each iteration, I will extract all rows that have the beg_date <= the date of the iteration and end_date > the date of the iteration. I will count how many rows of this subset belongs to type 1, type 2, ... After I've done, I don't need this subset of data, so I want to remove it to speed up the next iteration.
Do you know how to subset and also "cut" the part from the original data? Thanks very much.