Announcement

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

  • Combine data from various column in only one column

    Hallo, I tried some days to get my problem fixed but I get no result so I hope someone could help me.

    I got some observation about Board of Director Member for a period of time. Some oft he members are in more then one board at a year.

    My data now looks like:
    C_bvdidnum C_name Year BMname BMfunction
    BD49743 Bank XYZ 2007 Person XY Board of Director
    BD49743 Bank XYZ 2007 Person XY Executive Member
    BD49743 Bank XYZ 2007 Person XY Risk Audit Member
    BD49743 Bank XYZ 2008 Person XY Board of Director
    BD49743 Bank XYZ 2008 Person XY Executive Member
    BD49743 Bank XYZ 2009 Person XY Board of Director
    BD49743 Bank XYZ 2010 Person XY Board of Director

    My aim is to generate only one column per year. So that the data looks like.

    C_bvdidnum C_name Year BMname BMfunction
    BD49743 Bank XYZ 2007 Person XY Board of Director Executive Member Risk Audit Member
    BD49743 Bank XYZ 2008 Person XY Board of Director Executive Member
    BD49743 Bank XYZ 2009 Person XY Board of Director
    BD49743 Bank XYZ 2010 Person XY Board of Director
    In the end I got around 20.000 observation, hope someone got a helpful cmd or advice how to handle this problem.

  • #2
    Gero Reincke This the Mata (Stata's matrix programming language) forum. Next time you have a Stata related question please post it in the General Forum.
    Anyway here is one soluation

    ​​​​​​​
    Code:
    bys c_bvdidnum c_name year bmname : gen id = _n
    reshape wide bmfunction , i(c_bvdidnum c_name year bmname) j(id)
    egen _temp = concat(bmfunction*) , punct(" ")
    drop bmfunction*
    rename _temp bmfunction

    Comment

    Working...
    X