Hi everyone! So I need to import a new variable 'x' from an excel dataset (ED) within a Stata dataset (SD). ED is aggregated at district level while SD is at the individual level. While there is a common identifier in both for district level, I want to import values of x from ED into SD. The issue here is, each district is repeated several times in SD (individuals belonging to the same district), so I want values of x to be repeating for such repeating districts. I also have a time dummy, so I will be importing x from two different EDs depending on the time. Here is a small sample of my data with district & time identifiers.
Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input long STATE_DISTID float time
105 0
1012 0
1013 1
3010 0
3017 0
400 0
605 0
7010 0
805 1
806 1
806 1
808 0
8015 1
8032 1
9041 1
9045 1
9049 1
10014 1
10014 0
10017 1
10032 1
10035 0
1100 0
1906 0
1906 1
1909 0
19011 1
2002 0
2207 0
22014 1
2309 1
23017 0
23017 0
23021 0
23027 0
23028 1
23028 0
2408 0
24019 1
27021 1
27030 1
28013 1
2902 0
2906 0
29010 0
29018 0
29018 0
29018 1
33012 0
33012 0
end
I am not sure how to include a sample of an excel file here, please let me know if you do need that to come up with a solution. Thank you!
0 Response to Merging/Appending excel dataset
Post a Comment