- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Dear Madam/Sir,
I would like to pick control firms (gvkey2 in dataset2 with respect to gvkey1 and year) using treatment firms (gvkey and merge_year in the same industry_code in dataset 1).
Have
dataset 1 dataset 2
gvkey merge_year industry_code gvkey1 year gvkey2
Want
new dataset (matching identifier: gvkey(dataset1)=gvkey1(dataset2), merge_year(dataset2)=year(dataset2))
gvkey merge_year industry_code gvkey2
Any programming idea will be highly appreciated. Two datasets are attached.
Sincerely,
Joon
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
@joon1 wrote:
I would like to pick control firms (gvkey2 in dataset2 with respect to gvkey1 and year) using treatment firms (gvkey and merge_year in the same industry_code in dataset 1).
Have
dataset 1 dataset 2
gvkey merge_year industry_code gvkey1 year gvkey2
Want
new dataset (matching identifier: gvkey(dataset1)=gvkey1(dataset2), merge_year(dataset2)=year(dataset2))
gvkey merge_year industry_code gvkey2
Any programming idea will be highly appreciated. Two datasets are attached.
I don't understand your task well enough to consider this a program question yet. My questions are:
- Your dataset2 apparently does not have an industry code variable, a variable that you want for matching. Does that mean all pairs of gvkey1/gvkey2 in dataset2 represent companies already known to have the same industry code for the designated year? Or do you need to search dataset1 to confirm whether two distinct GVKEY's have the same industry code in the same year?
- Assuming the industry code match mystery is resolved.
- What if, for a given gvkey1 in dataset1, there are no records in dataset2 with year=merge_year from dataset1?
- More generally what if there are N gvkey's in dataset1 all sharing the same merge_year and industry code but there are fewer than N matches available in dataset2?
- On the other hand, what if there are more than N dataset2 records that can match a set of N records in dataset1 with a given merge_year? (this answer is probably self-evident, but please humor me).
The hash OUTPUT method will overwrite a SAS data set, but not append. That can be costly. Consider voting for Add a HASH object method which would append a hash object to an existing SAS data set
Would enabling PROC SORT to simultaneously output multiple datasets be useful? Then vote for
Allow PROC SORT to output multiple datasets
--------------------------
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for insightful comments, mkeintz.
You are correct. To simplify programming, I have dropped observations that have different industry (SIC code) between gvkey1 and gvkey 2 in dataset 2 to have only observations with the same industry between gvkey1 and gvkey2. The industry issue is resolved. I attach a part of revised dataset2 (it is over 8 million observations). For your a second serious questions, my goal is to have unique control firms (gvkey2) in a particular year that match between gvkey/merge_year in dataset1 and gvkey1/year in dataset 2. It could be multiple control firms (gvkey2) matched with gvkey in dataset 1 in a particular year.
Any programming advice will be highly appreciated.
Thanks
Joon1