Dear all,
I am currently working on my masterthesis. For this thesis, I am preparing a dataset which involves creating new variables.
I have a time panel data set that identifies each observations by a company code (cik) and a specific time period (a combination of year and quarter: fyq "2008Q2").
So for each cik, I have multiple observations for different time periods.
Now, I want to create a new variable which must be equal to the year of fyq for the first observation of cik code. So e.g.:
For each of the observations below I want that newvariable is equal to 2006.
cik fyq
0000921082 2006Q4
0000921082 2007Q1
0000921082 2007Q2
0000921082 2007Q3
0000921082 2007Q4
0000921082 2008Q1
0000921082 2008Q2
0000921082 2008Q4
0000921082 2009Q1
And for these observations I want that newvariable is equal to 2007
cik fyq
0001009976 2007Q1
0001009976 2007Q2
0001009976 2007Q3
0001009976 2007Q4
0001009976 2008Q1
0001009976 2008Q2
0001009976 2008Q4
0001009976 2009Q1
0001009976 2009Q3
0001009976 2010Q1
0001009976 2010Q2
0001009976 2010Q3
0001009976 2010Q4
0001009976 2011Q3
All the observations are available in the same dataset.
How can I achieve this?
Thanks in advance!
Iris
Related Posts with Generate variable with conditions
Comparing and assessing the fit of SUR models in StataI have two SUR models for which I want to assess the fit. I understand there is controversy as to wh…
Interpret coefficients measured in percent on binary dependent variable in panelHello Statalist members, reading in the forum has helped me at lot in the last weeks, but I cannot …
F-Test or T-TestHi guys, I have a question that is not regarding to Stata particually but to statistics in general.…
Survival analysis, discrete time - question on the model set up and goodness of fitHello Statalisters, I am trying to teach myself survival analysis estimation in STATA and at the mo…
Panel Data - Create variable that sums neighbors into group variableHello Experts, I am using country-year panel data using all countries from 1998-2017 with 3772 obser…
Subscribe to:
Post Comments (Atom)
0 Response to Generate variable with conditions
Post a Comment