Hi All,

My data is individual level data. There are a series of variables, with "date" and then six numbers representing the month and year. So for example, date011990 means January of 1990, date 021990 mean February 1990, etc.

For an individual, these usually start with zeros, and at some point the value is not zero, which is what I am interested in (month and year payment first started being received). I want to locate the first time the value is not zero, and pull out that information from the variable name.

ID date011990 date021990 ..... date041995 date051995 date061995 ..... date121997 date011998 date021998
70 0 0 0 940 940 1010 1010 1010
71 0 750 830 830 830 890 890 890
72 0 0 0 0 0 0 1230 1230

For each ID, I want two to create new variables "Month" and "Year"

Person 70, month = 05, year =1995
Person 71 month = 02, year = 1990
Person 72 month = 01, year =1998

This is the end product I want:


ID date011990 date021990 ..... date041995 date051995 date061995 ..... date121997 date011998 date021998 month year
70 0 0 0 940 940 1010 1010 1010 05 1995
71 0 750 830 830 830 890 890 890 02 1990
72 0 0 0 0 0 0 1230 1230 01 1998

Thanks!