Announcement

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

  • Convert into panel data

    Hi there,

    I would like to convert the dataset in a form of panel, where I have 'popestimate' and 'npopchg' for each 'geo_id' from years 2000 to 2004.

    In my dataset, I have the observations as separate variables, but I would like to create a 'year' variable so that I can create a panel.

    Below is part of the dataset:
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input str5 geo_id long(census2000pop estimatesbase2000 popestimate2000 popestimate2001 popestimate2002 popestimate2003 popestimate2004 npopchg_2000 npopchg_2001 npopchg_2002 npopchg_2003 npopchg_2004)
    "01000" 4447100 4447207 4451497 4463343 4471462 4489876 4510588  4290  11846   8119  18414  20712
    "01001"   43671   43751   43952   44509   45207   45762   46948   201    557    698    555   1186
    "01003"  140415  140416  141384  145017  148177  151798  156640   968   3633   3160   3621   4842
    "01005"   29038   29042   29039   29221   29285   29501   29462    -3    182     64    216    -39
    "01007"   20826   19856   19881   20866   20906   20975   21133    25    985     40     69    158
    "01009"   51024   50982   51141   51961   52753   53739   54471   159    820    792    986    732
    "01011"   11714   11603   11585   11353   11241   11287   11011   -18   -232   -112     46   -276
    "01013"   21399   21394   21275   20997   20570   20507   20448  -119   -278   -427    -63    -59
    "01015"  112249  111882  110986  110671  110532  111088  111300  -896   -315   -139    556    212
    "01017"   36583   36600   36552   36242   35921   35618   35373   -48   -310   -321   -303   -245
    "01019"   23988   23909   23963   23987   24058   24086   24213    54     24     71     28    127
    "01021"   39593   39604   39892   40140   40576   40913   41297   288    248    436    337    384
    "01023"   15922   15953   15879   15680   15371   15201   14925   -74   -199   -309   -170   -276
    "01025"   27867   27870   27797   27601   27248   27067   26930   -73   -196   -353   -181   -137
    "01027"   14254   14240   14239   14230   14145   14045   13913    -1     -9    -85   -100   -132
    "01029"   14123   14141   14146   14184   14365   14379   14262     5     38    181     14   -117
    "01031"   43615   43639   43536   43567   43675   43945   44539  -103     31    108    270    594
    "01033"   54984   54979   55004   54818   54581   54333   54431    25   -186   -237   -248     98
    "01035"   14089   14077   14008   13865   13675   13423   13222   -69   -143   -190   -252   -201
    "01037"   12202   11842   11794   11699   11499   11388   11121   -48    -95   -200   -111   -267
    "01039"   37631   37640   37496   36942   36666   36513   36334  -144   -554   -276   -153   -179
    "01041"   13665   13657   13672   13675   13555   13542   13579    15      3   -120    -13     37
    "01043"   77483   77426   77528   77611   77778   78124   78708   102     83    167    346    584
    "01045"   49129   49120   49051   48962   48866   48493   48273   -69    -89    -96   -373   -220
    "01047"   46365   46361   46136   45863   44909   44496   43913  -225   -273   -954   -413   -583
    "01049"   64452   64436   64633   65512   65551   66058   66608   197    879     39    507    550
    "01051"   65874   65819   66194   67531   68764   70055   71142   375   1337   1233   1291   1087
    end
    I'm not sure if -reshape- will work since I have several variables to convert.

    thank you for your help in advance!

  • #2
    Code:
    reshape long popestimate npopchg_,i(geo_id) j(year)

    Comment


    • #3
      Thank you so much!!

      Comment

      Working...
      X