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
How to add value label to default missing values?Hi there, Sorry for a really beginner question. I am trying to add value labels to organise my data…
Using a cross sectional analysis to support the results of a panel analysisHi all, I have a 3 wave panel of children's height and weight and whether either of their parents e…
Paneldata with feDear Statalists, I'm using a panel dataset on U.S. imports to the EU including tariff changes for s…
Meta-Analyses-HeterogeneityHello, I ran a pairwise meta-analyses in STATA and i found high level of heterogeneity, so i want to…
MimrgnsHi I'am trying to obtain margins after MI estimate and test differences between each slopes by a gro…
Subscribe to:
Post Comments (Atom)
0 Response to Identify first non zero value, create new variable
Post a Comment