I am trying to merge a shapefile with a panel data (i=location and j=month). Despite following the instructions in intro 4 here: https://www.stata.com/manuals/sp.pdf (particularly step 7b on page 35), the procedure still returns an error - it refuses to recognize the data as a panel.
Thanks.
Code:
. use "C:\Users\achan\Dropbox\Research\demon\data\inter\Census_2011D.dta"
. spset
Sp dataset Census_2011D.dta
data: cross sectional
spatial-unit id: _ID (equal to census_no)
coordinates: _CY, _CX (latitude-and-longitude, kilometers)
linked shapefile: Census_2011D_shp.dta
. use "C:\Users\achan\Dropbox\Research\demon\data\inter\radpanel2015m.dta"
(Excludes pixels>2800, Delhi merged to one dist/state, 2015 Annual VIIRS Mask)
. xtset
panel variable: census_no (strongly balanced)
time variable: yrmonth, 627 to 695
delta: 1 unit
. spbalance
(data strongly balanced)
. sum
Variable | Obs Mean Std. Dev. Min Max
-------------+---------------------------------------------------------
census_no | 43,677 322.8562 184.4444 0 640
OBJECTID | 43,677 317 182.7332 1 633
rad | 43,677 12659.59 18284.97 0 351883.8
yrmonth | 43,677 661 19.91672 627 695
. merge m:1 census_no using "C:\Users\achan\Dropbox\Research\demon\data\inter\Census_2011D.dta"
Result # of obs.
-----------------------------------------
not matched 0
matched 43,677 (_merge==3)
-----------------------------------------
. spset
Sp dataset radpanel2015m.dta
data: cross sectional
spatial-unit id: _ID (equal to census_no)
coordinates: _CY, _CX (latitude-and-longitude, kilometers)
linked shapefile: Census_2011D_shp.dta
variable _ID does not uniquely identify the observations
Do these data need to be xtset?
r(459);
. xtset
panel variable: census_no (strongly balanced)
time variable: yrmonth, 627 to 695
delta: 1 unit

Comment