Dear fellow stata-users. To perform a 4-factor Fama and French regression, i have to make yearly book-to-market portfolio's, based on the MarketCapitalization in June = (JuneMKT) and the Bookvalue of December of the previous year June of the current year. Therefore i did create (JundecBook). So as you can see below, i can calculate the book to market (JundecBook/JuneMKT) on the row of June (number month == 6).
NOTE: Indicate the Market Cap in june
. gen JuneMKT =MKTvaltCRSP if numbermonth ==6
(256,144 missing values generated)
NOTE: Indicate the bookvalue in December
gen DecBook = ADJCEQ if numbermonth ==12
(256,585 missing values generated)
NOTE: creating a laf for DecBook to have it on the same row as JuneMKT
by permno: gen JuneDecBook = DecBook[_n-6]
(258,691 missing values generated)
And than
. gen bTmDecJun = JunedecBook / JuneMKT
(256,144 missing values generated)

But i do endure the problem that during merging datasets previous to this stage, i deleted some observations making some monthly observations being also dropped, resulting in missing month for some years per company.
Either the month 6 is missing, which is critical for identification of the JuneMKT or month 12 indicating the DecBook. See below

Which code can help me to identify if all 12 month are present in a year, and thus also the accounting data needed for sorting stocks into the portfolios? Of course i can group the months into year per company, but how do i assign a dropping of those with less than 12 months? This should be necessary as otherwise the book-to-market value of the previous year complete with 12 months will continue to present the unfollowing incomplete year.
When i want to represent the book value from june till june:
NOTE: need to fill in the missing values in the rest of the sample year. Previous "11 month it applies to"
. replace bTmDecJun = bTmDecJun[_n-1] if bTmDecJun >= .
(256,137 real changes made)
But this don't work when there are missing values, because the complete B-t-M is than also applied to the next incomplete year without any new DecBook or JuneMKT value. See below!
So how can i identify that in a sequence of 12 months, some sequences are incomplete?

So how can i identify that in a sequence of 12 months, some sequences are incomplete?
Thank you in advance!
Yours sincerely,
Thomas Hunfeld
NOTE: Indicate the Market Cap in june
. gen JuneMKT =MKTvaltCRSP if numbermonth ==6
(256,144 missing values generated)
NOTE: Indicate the bookvalue in December
gen DecBook = ADJCEQ if numbermonth ==12
(256,585 missing values generated)
NOTE: creating a laf for DecBook to have it on the same row as JuneMKT
by permno: gen JuneDecBook = DecBook[_n-6]
(258,691 missing values generated)
And than
. gen bTmDecJun = JunedecBook / JuneMKT
(256,144 missing values generated)
But i do endure the problem that during merging datasets previous to this stage, i deleted some observations making some monthly observations being also dropped, resulting in missing month for some years per company.
Either the month 6 is missing, which is critical for identification of the JuneMKT or month 12 indicating the DecBook. See below
Which code can help me to identify if all 12 month are present in a year, and thus also the accounting data needed for sorting stocks into the portfolios? Of course i can group the months into year per company, but how do i assign a dropping of those with less than 12 months? This should be necessary as otherwise the book-to-market value of the previous year complete with 12 months will continue to present the unfollowing incomplete year.
When i want to represent the book value from june till june:
NOTE: need to fill in the missing values in the rest of the sample year. Previous "11 month it applies to"
. replace bTmDecJun = bTmDecJun[_n-1] if bTmDecJun >= .
(256,137 real changes made)
But this don't work when there are missing values, because the complete B-t-M is than also applied to the next incomplete year without any new DecBook or JuneMKT value. See below!
So how can i identify that in a sequence of 12 months, some sequences are incomplete?
So how can i identify that in a sequence of 12 months, some sequences are incomplete?
Thank you in advance!
Yours sincerely,
Thomas Hunfeld
Comment