Announcement

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

  • collapsing on one variable without losing columns

    hi all! i am working off of a data set of wind turbines, and i want to turn it into a dataset of wind farms. basically, anything with the same p_name and same number of turbines (p_tnum) should become one project all in one row. i've used the collapse command to collapse mean p_tnum by p(name), but then i lose all my other variables. I want to keep all the other variables, particularly t_state, but need only one row per p_name. how do i achieve this???
    Attached Files

  • #2
    If the other variables all have the same value for all observations of a specific p_name, then you can do something like:
    Code:
    collapse (mean) p_tnum (first) t_state var2 var3 var4 var5 ... , by(p_name)

    Comment


    • #3
      I want to keep all the other variables...[emphasis added]
      But how can you keep case_id, faa_ors, faa_asn, usgs_pr_id, t_county, and t_fips? Each of these variables sometimes takes on different values within the group of observations defined by p_name and t_manu. Which of those values should Stata retain for your single observation?

      Comment

      Working...
      X