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!
Related Posts with Identify first non zero value, create new variable
Difference in Difference Model: Refine the definition of treatment and control groupHi all, I try to establish a standard DiD model with fixed effect to investigate the impacts of a m…
Comparing string values within the same variableHi folks, I have a database with +70k observations. I am looking at school principals turnover of +…
Weak instrument test for RE estimationHello! I was wondering if anyone could provide me with some guidance as to what weak instrument test…
Plotting Different Regression Values in One Graph with CoefplotHello there, I'm currently running a series of regressions using US State data. So far, I've create…
GMM estimation: when one of dependent variables minus a constantDear everyone, I had noticed a very interesting phenomenon in GMM estimation, which I can't figure …
Subscribe to:
Post Comments (Atom)
0 Response to Identify first non zero value, create new variable
Post a Comment