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
Explanatory and explained variables with opposite time trendsDear All! I am conducting a cross-country study exploring the relationship between ESG disclosure …
Struggling to create a percent change variable that is organized by multiple subgroupingsHi all! Apologies for the possibly beginner question, I've been searching this forum all afternoon a…
Generate 2nd Highest ValueHi, This was supposed to be easy, but its not, for me anyway. I need to generate a new variable tha…
Continuous variable Treatment Group in DID RegressionI am struggling to understand how to interpret the treatment and control group in the following case…
Microfinance or Self Help GroupHi everyone, I am writing a desk-based research paper for my class on "impact of Microfinance (or S…
Subscribe to:
Post Comments (Atom)
0 Response to Identify first non zero value, create new variable
Post a Comment