As follows I describe my puzzle:
Dataset 1
variables: date cusip prc ret shroutDataset 2
variables: fyear cusip bkvlps csho ggroup gsector
The time observations in Dataset 2 are in annual basis, whilst those in Dataset 1 are in monthly basis. Each cusip value corresponds to one unique company and so in Dataset 1 cusip values are repeated for all months when the company´s stock traded.
What I need to do is to set the variables bkvlps csho ggroup gsector from dataset 2, for which I have one observation per year (D2: fyear) and per company (cusip) repeatedly for every month (D1: date) in dataset 1 that belongs to that particular year (D2: fyear) and it must also coincide for that given company (cusip). Therefore, at the end, I should have a unique dataset that has the variables date cusip prc ret shrout bkvlps csho ggroup gsector wherein the variables bkvlps csho ggroup gsector repeat accordingly to cusip and to date depending on whether the month in date coincides with one within the year fyear.
Dataset 1
Array
Dataset 2
Array
In the images you can observe only one cusip, ggroup, and gsector, but the variable cusip changes and is unique for each different firm while the ggroup and gsector remain constant across the time-series for each cusip but are not unique to that particular company as is the cusip.
If you need any more information to help me with this puzzle, do not hesitate in asking me.
Thank you for your time and attention.
0 Response to Unifiying databases
Post a Comment