Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • What causes the following error: data not spset r(459);

    copy http://www.stata-press.com/data/r15/homicide1990.dta ., replace
    copy http://www.stata-press.com/data/r15/...de1990_shp.dta, replace
    use homicide1990
    spset

    Sp dataset: homicide1990.dta
    Linked shapefile: homicide1990_shp.dta
    Data: Cross sectional
    Spatial-unit ID: _ID
    Coordinates: _CX, _CY (planar)

    I followed the above command to operate, but the following error message appeared:
    . spset
    data not spset
    r(459);

    part of my data as follows:
    panneldata.dta

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input byte _ID double(_CX _CY) int year
     1 117.189830557 39.1180173743 2010
     1 117.189830557 39.1180173743 2011
     1 117.189830557 39.1180173743 2012
     1 117.189830557 39.1180173743 2013
     1 117.189830557 39.1180173743 2014
     1 117.189830557 39.1180173743 2015
     1 117.189830557 39.1180173743 2016
     1 117.189830557 39.1180173743 2017
     1 117.189830557 39.1180173743 2018
     1 117.189830557 39.1180173743 2019
     2 117.248888084  39.119526284 2010
     2 117.248888084  39.119526284 2011
     2 117.248888084  39.119526284 2012
     2 117.248888084  39.119526284 2013
     2 117.248888084  39.119526284 2014
     2 117.248888084  39.119526284 2015
     2 117.248888084  39.119526284 2016
     2 117.248888084  39.119526284 2017
     2 117.248888084  39.119526284 2018
     2 117.248888084  39.119526284 2019
     3 117.222587945 39.0788598222 2010
     3 117.222587945 39.0788598222 2011
     3 117.222587945 39.0788598222 2012
     3 117.222587945 39.0788598222 2013
     3 117.222587945 39.0788598222 2014
     3 117.222587945 39.0788598222 2015
     3 117.222587945 39.0788598222 2016
     3 117.222587945 39.0788598222 2017
     3 117.222587945 39.0788598222 2018
     3 117.222587945 39.0788598222 2019
     4 117.149842042 39.1099282567 2010
     4 117.149842042 39.1099282567 2011
     4 117.149842042 39.1099282567 2012
     4 117.149842042 39.1099282567 2013
     4 117.149842042 39.1099282567 2014
     4 117.149842042 39.1099282567 2015
     4 117.149842042 39.1099282567 2016
     4 117.149842042 39.1099282567 2017
     4 117.149842042 39.1099282567 2018
     4 117.149842042 39.1099282567 2019
     5 117.207713401 39.1661096691 2010
     5 117.207713401 39.1661096691 2011
     5 117.207713401 39.1661096691 2012
     5 117.207713401 39.1661096691 2013
     5 117.207713401 39.1661096691 2014
     5 117.207713401 39.1661096691 2015
     5 117.207713401 39.1661096691 2016
     5 117.207713401 39.1661096691 2017
     5 117.207713401 39.1661096691 2018
     5 117.207713401 39.1661096691 2019
     6 117.149244159 39.1635590895 2010
     6 117.149244159 39.1635590895 2011
     6 117.149244159 39.1635590895 2012
     6 117.149244159 39.1635590895 2013
     6 117.149244159 39.1635590895 2014
     6 117.149244159 39.1635590895 2015
     6 117.149244159 39.1635590895 2016
     6 117.149244159 39.1635590895 2017
     6 117.149244159 39.1635590895 2018
     6 117.149244159 39.1635590895 2019
     7  117.40260969 39.1327213549 2010
     7  117.40260969 39.1327213549 2011
     7  117.40260969 39.1327213549 2012
     7  117.40260969 39.1327213549 2013
     7  117.40260969 39.1327213549 2014
     7  117.40260969 39.1327213549 2015
     7  117.40260969 39.1327213549 2016
     7  117.40260969 39.1327213549 2017
     7  117.40260969 39.1327213549 2018
     7  117.40260969 39.1327213549 2019
     8 117.113174484 39.0277847396 2010
     8 117.113174484 39.0277847396 2011
     8 117.113174484 39.0277847396 2012
     8 117.113174484 39.0277847396 2013
     8 117.113174484 39.0277847396 2014
     8 117.113174484 39.0277847396 2015
     8 117.113174484 39.0277847396 2016
     8 117.113174484 39.0277847396 2017
     8 117.113174484 39.0277847396 2018
     8 117.113174484 39.0277847396 2019
     9 117.379474377 38.9635323103 2010
     9 117.379474377 38.9635323103 2011
     9 117.379474377 38.9635323103 2012
     9 117.379474377 38.9635323103 2013
     9 117.379474377 38.9635323103 2014
     9 117.379474377 38.9635323103 2015
     9 117.379474377 38.9635323103 2016
     9 117.379474377 38.9635323103 2017
     9 117.379474377 38.9635323103 2018
     9 117.379474377 38.9635323103 2019
    10 117.166787112 39.2520169888 2010
    10 117.166787112 39.2520169888 2011
    10 117.166787112 39.2520169888 2012
    10 117.166787112 39.2520169888 2013
    10 117.166787112 39.2520169888 2014
    10 117.166787112 39.2520169888 2015
    10 117.166787112 39.2520169888 2016
    10 117.166787112 39.2520169888 2017
    10 117.166787112 39.2520169888 2018
    10 117.166787112 39.2520169888 2019
    end
    format %ty year
    panneldata_shp.dta

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input byte _ID double(_X _Y)
    1                  .                  .
    1 117.18792660500014  39.13375092500004
    1 117.18808842500005 39.133300120000044
    1 117.18815981000009  39.13314707000008
    1 117.18832900500014  39.13278431500009
    1 117.18885797500012 39.132092845000074
    1 117.18990150000013  39.13110622000015
    1 117.19015409500017  39.13087292000012
    1 117.19045956000012 39.130616755000155
    1 117.19111723500009  39.13015598500013
    1  117.1914061300001 39.130008130000064
    1 117.19172133000006 39.129860230000084
    1 117.19206818000008  39.12974503000006
    1 117.19232318500005 39.129661785000096
    1 117.19257929000008  39.12960562500007
    1 117.19281737500016  39.12957090500004
    1 117.19316967000009  39.12952529000008
    1 117.19359037500008 39.129491840000156
    1 117.19403743500004 39.129478810000144
    1  117.1945319400001 39.129502555000066
    1 117.19515578000002   39.1296081200001
    1  117.1953230450001  39.12965776500003
    1 117.19612967500004  39.12989715500012
    1  117.1968420150001 39.130155550000005
    1 117.19742652500005  39.13038791500005
    1 117.19789674500007 39.130604405000106
    1 117.19909778500005  39.13122463500009
    1 117.19975831500008   39.1315854850001
    1 117.20023763500012  39.13181392500009
    1 117.20045885000013  39.13191589000009
    1 117.20088013500018 39.132083015000056
    1 117.20136975500009  39.13223365000009
    1 117.20189620500013  39.13238421500011
    1 117.20234640000015 39.132465865000114
    1 117.20293051500008  39.13254673000006
    1 117.20314097500008  39.13256683000012
    1 117.20355978750007 39.132577340000104
    1 117.20394263500008 39.132583445000165
    1 117.20408525500015 39.132585575000164
    1 117.20430160750016  39.13257832250014
    1 117.20462699000004 39.132564155000075
    1 117.20501087500008  39.13252663500008
    1 117.20524746000012 39.132485280000125
    1 117.20560481500011  39.13237002000009
    1 117.20594101000003 39.132213860000135
    1  117.2061930100001 39.132045560000066
    1 117.20636277500012 39.131896420000075
    1  117.2065095350001  39.13171602500007
    1 117.20665617000006  39.13149469500014
    1 117.20677650500008  39.13127341000004
    1 117.20689119500014 39.130921130000026
    1 117.20694839000008  39.13059187500005
    1 117.20699973500007       39.130161925
    1 117.20704590500006  39.12971824500006
    1 117.20705820500011  39.12951628000005
    1  117.2070860550001 39.129059050000144
    1 117.20711590500017 39.128475810000026
    1 117.20716190500016 39.128017210000095
    1 117.20720818500017  39.12764225000016
    1 117.20728059500004  39.12722454000006
    1 117.20736332000013  39.12695981000009
    1 117.20765654500005  39.12602143000007
    1 117.20787049500008  39.12544380500007
    1  117.2080543300001  39.12501131500007
    1 117.20854830000012  39.12422666500008
    1 117.20890273500004 39.123742220000054
    1 117.20935055000007  39.12316622500009
    1 117.21037539500013 39.121982370000104
    1 117.21128350500013 39.120946745000126
    1 117.21196630000013  39.12024941500007
    1 117.21372398000008  39.11861467500008
    1  117.2150703500001  39.11742399500006
    1 117.21599833000013  39.11658866750009
    1 117.21615873500018 39.116441470000034
    1 117.21200480500012  39.11449452000015
    1 117.19950387000016  39.10789954750013
    1 117.19712600000014  39.10646068000005
    1 117.19700335500012  39.10637914000005
    1 117.19689071000005 39.106291180000056
    1 117.19274723500004  39.10304420000008
    1 117.19027226000017  39.10075888500008
    1 117.19030070000012  39.10057135000011
    1 117.18337815500013  39.09993372500002
    1 117.17317005000008  39.10096173000008
    1 117.17294518928577    39.100977997143
    1 117.17298182500005  39.10183404500005
    1 117.17299683500005 39.102184750000106
    1 117.17306624000011  39.10380654000009
    1  117.1731283500001  39.10525771500008
    1 117.17339208000007  39.11877117500015
    1 117.17348320000005 39.120430450000036
    1 117.17352839500006  39.12100406000016
    1 117.17481768500008 39.135466650000154
    1 117.17482557250005 39.135824117500114
    1 117.17483898000015  39.13603978000006
    1 117.18414058500016 39.135780170000075
    1 117.18792660500014  39.13375092500004
    2                  .                  .
    2 117.26772796000014  39.15758910500004
    2 117.26865856000003 39.155778960000106
    end

    The two files panneldata.dta and panneldata_shp.dta are placed in the same folder, but when using the spset command, the following error message pops up:

    . spset
    data not spset
    r(459);

    I want to know the cause of the error and how to solve the problem

    thank you very much

  • #2
    When you type spset you display the current setting. To set the data,
    Code:
    spset _ID

    Comment


    • #3
      xtset _ID year

      Panel variable: _ID (strongly balanced)
      Time variable: year, 2010 to 2019
      Delta: 1 year


      code

      . spset _ID
      invalid panel setting
      Type xtset to view panel data settings.
      r(459);


      . spset
      data not spset

      Comment


      • #4
        Code:
        egen id2 = group(_ID year)
        spset id2
        also,
        Code:
        help spset

        Comment


        • #5

          . spset id2
          data not strongly balanced
          Use spbalance to balance the data. Then type spset again to verify that all went well.
          r(459);

          xtset id2 year // weakly balanced)

          Panel variable: id2 (weakly balanced)
          Time variable: year, 2010 to 2019
          Delta: 1 year

          but for _ID
          xtset _ID year // strongly balanced

          Panel variable: _ID (strongly balanced)
          Time variable: year, 2010 to 2019
          Delta: 1 year


          Comment


          • #6
            after spbalance,
            spset _ID
            spset

            then it can be displayed normally, no more error prompts

            Comment


            • #7
              but
              spset _ID

              Sp dataset: panneldatalast.dta
              Linked shapefile: <none>
              Data: Panel
              Spatial-unit ID: _ID
              Time ID: year (see xtset)
              Coordinates: <none>

              . spset

              Sp dataset: panneldatalast.dta
              Linked shapefile: <none>
              Data: Panel
              Spatial-unit ID: _ID
              Time ID: year (see xtset)
              Coordinates: <none>

              but it cann't link the relate shapefile, and the subsequent spatial measurement analysis cannot be carried out

              . spmatrix create contiguity W
              Sp data not linked to shapefile
              Type spset, modify filename(<filename>_shp.dta) to link a _shp.dta file to the dataset in memory.
              r(601);

              Comment


              • #8
                Hi! Were you able to figure this out?

                Comment

                Working...
                X