Hi everyone,
I am facing a problem with merging specific columns from various stata files. My base file looks like the following:
Now I want to merge that file with the two following files (excerpt):
and
What is important to me is that I only add the columns which have the same name as the observations in the varlist „id“ from the base file. The original files have more columns than Stata can handle. Hence, I need to merge only the specific columns; it is no option to merge all the columns and then to delete those that do not match.
My goal is to have the following file (leaving out the columns for rd12 and rd99 as these are not ids in the first file):
I would really appreciate it if someone knew how to do this as I tried various Things which all did not work.
Thank you very much!
Nina
I am facing a problem with merging specific columns from various stata files. My base file looks like the following:
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float date str4 id 20068 "rd5" 20115 "rd6" 20116 "rd7" 20123 "rd8" 20124 "rd8" 20124 "rd7" 20124 "rd5" end format %td date
Now I want to merge that file with the two following files (excerpt):
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(date rd12 rd7 rd8) 20068 7 5 2 20115 2 6 3 20116 1 7 4 20123 6 8 5 20124 7 9 6 20124 7 9 6 20124 7 9 6 end format %td date
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(date rd5 rd6 rd99) 20068 5 1 9 20115 4 4 7 20116 3 5 6 20123 8 2 1 20124 3 7 2 20124 3 7 2 20124 3 7 2 end format %td date
What is important to me is that I only add the columns which have the same name as the observations in the varlist „id“ from the base file. The original files have more columns than Stata can handle. Hence, I need to merge only the specific columns; it is no option to merge all the columns and then to delete those that do not match.
My goal is to have the following file (leaving out the columns for rd12 and rd99 as these are not ids in the first file):
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float date str4 id float(rd5 rd6 rd8 rd7) 20068 "rd5" 5 1 2 5 20115 "rd6" 4 4 3 6 20116 "rd7" 3 5 4 7 20123 "rd8" 8 2 5 8 20124 "rd8" 3 7 6 9 20124 "rd7" 3 7 6 9 20124 "rd5" 3 7 6 9 end format %td date
Thank you very much!
Nina
Comment