Hi all,
I need to merge two datasets, but only if two variables from both dataset match. First dataset here is showing a day of one particular month, county, state, FIPS, etc.
[CODE]
* Example generated by -dataex-. To install: ssc install dataex
clear
input byte DAY str33 COUNTY str24 STATE long(FIPS CASES) int(DEATHS CASE2WK DEATHS2WK)
7 "Autauga" "Alabama" 1001 1113 22 181 1
11 "Autauga" "Alabama" 1001 1215 23 228 2
12 "Autauga" "Alabama" 1001 1241 23 239 2
13 "Autauga" "Alabama" 1001 1250 23 235 2
14 "Autauga" "Alabama" 1001 1252 23 222 2
15 "Autauga" "Alabama" 1001 1262 23 210 2
16 "Autauga" "Alabama" 1001 1273 23 207 2
17 "Autauga" "Alabama" 1001 1274 23 201 2
18 "Autauga" "Alabama" 1001 1291 23 218 1
19 "Autauga" "Alabama" 1001 1298 23 202 1
20 "Autauga" "Alabama" 1001 1298 23 185 1
21 "Autauga" "Alabama" 1001 1313 23 179 1
22 "Autauga" "Alabama" 1001 1322 23 105 1
23 "Autauga" "Alabama" 1001 1324 23 102 1
24 "Autauga" "Alabama" 1001 1351 23 136 0
25 "Autauga" "Alabama" 1001 1355 23 114 0
26 "Autauga" "Alabama" 1001 1366 23 116 0
27 "Autauga" "Alabama" 1001 1377 23 125 0
28 "Autauga" "Alabama" 1001 1389 23 127 0
29 "Autauga" "Alabama" 1001 1400 23 127 0
30 "Autauga" "Alabama" 1001 1438 23 164 0
31 "Autauga" "Alabama" 1001 1442 23 151 0
7 "Baldwin" "Alabama" 1003 3504 25 842 7
11 "Baldwin" "Alabama" 1003 3736 32 828 11
12 "Baldwin" "Alabama" 1003 3776 32 748 11
13 "Baldwin" "Alabama" 1003 3813 32 712 10
14 "Baldwin" "Alabama" 1003 3860 32 718 10
15 "Baldwin" "Alabama" 1003 3909 32 686 9
16 "Baldwin" "Alabama" 1003 3948 32 683 8
17 "Baldwin" "Alabama" 1003 3960 32 640 8
18 "Baldwin" "Alabama" 1003 3977 33 597 9
19 "Baldwin" "Alabama" 1003 4002 33 564 8
20 "Baldwin" "Alabama" 1003 4035 34 531 9
21 "Baldwin" "Alabama" 1003 4075 35 511 9
22 "Baldwin" "Alabama" 1003 4115 35 509 8
23 "Baldwin" "Alabama" 1003 4147 35 433 7
24 "Baldwin" "Alabama" 1003 4167 35 431 3
The second dataset (much larger and not letting me use dataex) also has day (from one month) and FIPS. I need to merge the last four columns of the dataset above with the larger second dataset on day AND Fips. Basically, in first dataset the 7th, 11th, and 12-31st are repeated for ALL FIPS. The second dataset is survey so I need the last four columns for each respondent on the day they took survey and the FIPS they live. I hope this makes sense, sorry I am new to Stata. Please advise!
0 Response to merging datasets only if two variables match
Post a Comment