Announcement

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

  • Converting to Panel Data

    Hi All,

    I have got a data set with each row indicating a household technology installed in a location each year and over the years. I want to convert the data to panel data, by collapsing the various variables into the relevant single value/variable such as the number of technologies installed in a location for a particular year. This would involve counting each row. I believe we could also get summary values for other variables such as total subsidies provided in a location for a particular year by adding the subsidy amount across the rows for that year. My data is arranged as below.

    . . dataex id vdcname fiscal_year1 basesubsidy size_code in 1/20

    ----------------------- copy starting from the next line -----------------------
    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float id long vdcname float fiscal_year1 long basesubsidy byte size_code
    199096 1388 2013 35000 6
    199093 1388 2006  9500 6
    199094 1388 2013 35000 6
    199095 1388 2013 35000 6
    343760 2538 2006  9500 6
    343763 2538 2013 35000 6
    343764 2538 2013 35000 6
    343765 2538 2013 35000 6
    343761 2538 2007  9500 6
    343762 2538 2013 35000 6
    351035 2607 2007  9500 6
    351036 2607 2007  9500 6
    248427 1746 2012 35000 6
    248430 1746 2013 35000 6
    248426 1746 2012 35000 6
    248431 1746 2013 35000 6
    248432 1746 2013 35000 6
    248428 1746 2012 35000 6
    248429 1746 2013 35000 6
     22546   38 2012 35000 6
    end
    label values vdcname vdcname
    label def vdcname 38 "Ambegudin", modify
    label def vdcname 1388 "Khewang", modify
    label def vdcname 1746 "Mehel", modify
    label def vdcname 2538 "Surumakhim", modify
    label def vdcname 2607 "Tel Lok", modify
    ------------------ copy up to and including the previous line ------------------

    Listed 20 out of 368945 observations

    I would be thankful for any help.

    Samir

  • #2
    I cannot discern from your dataset and description which variable is the location and which is the household technology. I will speculate that vdcname is the location, and id is the household technology. If I guessed wrong, you can probably modify this code accordingly, but, if not, post back with a fuller explanation.

    Code:
    collapse (sum) basesubsidy (count) n_technologies = id, by(vdcname fiscal_year1)

    Comment


    • #3
      Thank you so much, Clyde.

      Comment

      Working...
      X