Dear statalist,

I am trying to solve the following problem:

I have 105 dummy variables for 105 months spanning Janury 2010 – September 2018, each taking the value 1 if something happened that month. They’re named mat201001, mat201002 … mat201809.

I need to generate a new variable, that will give me the month and year in which the event first occured, that is when a dummy variable first took the value 1. For example if the first dummy to take the value 1 was mat201202, the new variable would be 201202, if the first dummy to be 1 is mat201801, the new variable will be 201801.

Thank you!
Zuzana