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