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
p-value for comparison of adjusted curves from RocregHello, I am trying to compare two curves generated using rocreg - one curve that is not adjusted and…
Drop base variables from fvexpand listI want to modify the variable list produced by fvexpand, e.g. Code: . webuse nhanes2f, clear . f…
Gravity model, low R2-withinHi all ! I'm running a bilateral trade panel data of 42 reporter with 186 partner for the year 2015…
Is there no way to include "industry fixed effects" in an FE regression?Dear Stata community, I am running a model of the following form: xtset CompanyID Year, yearly xtr…
Clarification of Results InterpretationI am conducting a cross-sectional study of UK firms to investigate the relationship between boardroo…
Subscribe to:
Post Comments (Atom)
0 Response to Generate variable with conditions
Post a Comment