Dear all,

I am using Stata 16, on mac. First I collapsed the first dataset I have by state_fire_year, renamed objectid num_fires, and filled in 0's for years that were missing data. I then saved it as fire.dta. I then imported my second dataset, saved it as heatwave.dta. I then attempted to merge by the common variable state, but unfortunately it does not work . I receive the following error: variable state does not uniquely identify observations in the using data. I am not sure why this is happening.

Thank you so much in advance,
Jason Browen

Here is the Stata code I used:

clear

import delimited "/Users/MusicMelody/Downloads/Econ 798 Wildfire /National_Interagency_Fire_Occurrence_1992-2009__Feature_Layer_.csv", encoding(windows-1252)

collapse (mean) fire_size (count) objectid, by (state fire_year)

rename objectid num_fires

fillin state fire_year
foreach v of varlist fire_size num_fires {
replace `v' = 0 if _fillin
}

save fire.dta, replace

import delimited "/Users/MusicMelody/Documents/heatwavedays.csv", encoding(ISO-8859-2) clear

save heatwave.dta, replace

order fire_year state

save heatwave.dta, replace

use fire.dta, clear

merge m:1 state using heatwave.dta


First dataset code using dataex:

clear
input int fire_year str2 state float fire_size long num_fires byte _fillin
1992 "AK" 845.4313 166 0
1993 "AK" 1835.0476 361 0
1994 "AK" 978.6483 259 0
1995 "AK" 287.115 100 0
1996 "AK" 2834.401 210 0
1997 "AK" 6865.184 253 0
1998 "AK" 873.5494 91 0
1999 "AK" 5085.106 172 0
2000 "AK" 6232.033 116 0
2001 "AK" 2381.4448 89 0
2002 "AK" 10890.39 170 0
2003 "AK" 2144.9624 135 0
2004 "AK" 19558.28 324 0
2005 "AK" 14542.496 305 0
2006 "AK" 1266.0635 82 0
2007 "AK" 2424.6 237 0
2008 "AK" 474.5801 136 0
2009 "AK" 10521.876 210 0
1992 "AL" 11.719565 92 0
1993 "AL" 17.613386 127 0
1994 "AL" 17.252563 78 0
1995 "AL" 38.57459 122 0
1996 "AL" 34.062626 99 0
1997 "AL" 12.914286 49 0
1998 "AL" 36.578335 120 0
1999 "AL" 18.98855 131 0
2000 "AL" 23.41364 88 0
2001 "AL" 18.234694 49 0
2002 "AL" 32.120407 49 0
2003 "AL" 15.246522 23 0
2004 "AL" 45.5375 20 0
2005 "AL" 38.113075 39 0
2006 "AL" 38.87383 68 0
2007 "AL" 35.223362 122 0
2008 "AL" 49.64544 46 0
2009 "AL" 31.39926 27 0
1992 "AR" 10.87563 119 0
1993 "AR" 12.05143 140 0
1994 "AR" 14.071166 163 0
1995 "AR" 21.8021 238 0
1996 "AR" 23.90909 220 0
1997 "AR" 10.695902 122 0
1998 "AR" 9.717911 134 0
1999 "AR" 21.41359 184 0
2000 "AR" 11.825352 142 0
2001 "AR" 8.455102 98 0
2002 "AR" 19.925926 81 0
2003 "AR" 10.148214 28 0
2004 "AR" 32.092175 69 0
2005 "AR" 25.266064 127 0
2006 "AR" 116.66267 198 0
2007 "AR" 85.09666 99 0
2008 "AR" 9.895641 39 0
2009 "AR" 36.94042 48 0
1992 "AZ" 7.843952 3001 0
1993 "AZ" 33.54098 3787 0
1994 "AZ" 47.01427 3701 0
1995 "AZ" 56.44799 3736 0
1996 "AZ" 57.98333 3114 0
1997 "AZ" 4.958405 2231 0
1998 "AZ" 9.418039 2672 0
1999 "AZ" 29.67794 2289 0
2000 "AZ" 21.3262 3263 0
2001 "AZ" 7.746929 2719 0
2002 "AZ" 250.95998 2314 0
2003 "AZ" 70.169914 2461 0
2004 "AZ" 91.36715 2406 0
2005 "AZ" 178.81505 2813 0
2006 "AZ" 54.33685 2648 0
2007 "AZ" 50.6024 2035 0
2008 "AZ" 67.47714 1587 0
2009 "AZ" 104.68148 1942 0
1992 "CA" 49.96407 4072 0
1993 "CA" 110.02003 2406 0
1994 "CA" 114.69466 3054 0
1995 "CA" 69.35978 2332 0
1996 "CA" 171.43004 3366 0
1997 "CA" 87.69614 2719 0
1998 "CA" 32.95824 3520 0
1999 "CA" 156.7826 4734 0
2000 "CA" 61.48395 3165 0
2001 "CA" 68.10068 3709 0
2002 "CA" 105.53133 3019 0
2003 "CA" 183.17535 3484 0
2004 "CA" 37.700092 3082 0
2005 "CA" 23.83633 2558 0
2006 "CA" 163.4085 3699 0
2007 "CA" 187.89368 4548 0
2008 "CA" 535.5822 2175 0
2009 "CA" 173.84348 2101 0
1992 "CO" 4.59029 896 0
1993 "CO" 42.37123 789 0
1994 "CO" 31.81096 1578 0
1995 "CO" 8.884312 886 0
1996 "CO" 50.02913 1397 0
1997 "CO" 8.283611 720 0
1998 "CO" 10.953202 765 0
1999 "CO" 26.941114 754 0
2000 "CO" 55.5862 1536 0
2001 "CO" 11.419093 1147 0
end
[/CODE]


First dataset code using dataex:

input str2 state int(fire_year yearcode heat_wave_days)
"AK" 1992 1992 0
"AK" 1993 1993 0
"AK" 1994 1994 0
"AK" 1995 1995 0
"AK" 1996 1996 0
"AK" 1997 1997 0
"AK" 1998 1998 0
"AK" 1999 1999 0
"AK" 2000 2000 0
"AK" 2001 2001 0
"AK" 2002 2002 0
"AK" 2003 2003 0
"AK" 2004 2004 0
"AK" 2005 2005 0
"AK" 2006 2006 0
"AK" 2007 2007 0
"AK" 2008 2008 0
"AK" 2009 2009 0
"AL" 1992 1992 28
"AL" 1993 1993 110
"AL" 1994 1994 0
"AL" 1995 1995 364
"AL" 1996 1996 0
"AL" 1997 1997 90
"AL" 1998 1998 264
"AL" 1999 1999 496
"AL" 2000 2000 2139
"AL" 2001 2001 0
"AL" 2002 2002 40
"AL" 2003 2003 0
"AL" 2004 2004 13
"AL" 2005 2005 80
"AL" 2006 2006 966
"AL" 2007 2007 2036
"AL" 2008 2008 479
"AL" 2009 2009 2707
"AR" 1992 1992 0
"AR" 1993 1993 167
"AR" 1994 1994 0
"AR" 1995 1995 222
"AR" 1996 1996 6
"AR" 1997 1997 20
"AR" 1998 1998 1153
"AR" 1999 1999 682
"AR" 2000 2000 2120
"AR" 2001 2001 339
"AR" 2002 2002 0
"AR" 2003 2003 215
"AR" 2004 2004 32
"AR" 2005 2005 870
"AR" 2006 2006 2075
"AR" 2007 2007 1166
"AR" 2008 2008 386
"AR" 2009 2009 2147
"AZ" 1992 1992 8
"AZ" 1993 1993 30
"AZ" 1994 1994 175
"AZ" 1995 1995 154
"AZ" 1996 1996 117
"AZ" 1997 1997 72
"AZ" 1998 1998 96
"AZ" 1999 1999 10
"AZ" 2000 2000 137
"AZ" 2001 2001 62
"AZ" 2002 2002 182
"AZ" 2003 2003 242
"AZ" 2004 2004 17
"AZ" 2005 2005 167
"AZ" 2006 2006 182
"AZ" 2007 2007 176
"AZ" 2008 2008 98
"AZ" 2009 2009 263
"CA" 1992 1992 371
"CA" 1993 1993 141
"CA" 1994 1994 265
"CA" 1995 1995 80
"CA" 1996 1996 472
"CA" 1997 1997 273
"CA" 1998 1998 600
"CA" 1999 1999 142
"CA" 2000 2000 290
"CA" 2001 2001 427
"CA" 2002 2002 628
"CA" 2003 2003 654
"CA" 2004 2004 380
"CA" 2005 2005 352
"CA" 2006 2006 650
"CA" 2007 2007 403
"CA" 2008 2008 716
"CA" 2009 2009 870
"CO" 1992 1992 22
"CO" 1993 1993 37
"CO" 1994 1994 755
"CO" 1995 1995 425
"CO" 1996 1996 177
"CO" 1997 1997 109
"CO" 1998 1998 301
"CO" 1999 1999 24
"CO" 2000 2000 745
"CO" 2001 2001 480
end
[/CODE]