Creating flag variables for aggregation>