Dear All, I find this question here (https://bbs.pinggu.org/thread-6924503-1-1.html). The data is
and wish to reshape as
Any suggestions? It changes P* to be variable names, and for each id year, gives the value 1 if P* are included in TypeID.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input long id int year str41 TypeID 4 2010 "P2503,P2515,P2599" 4 2011 "P2503 P2504 P2505" 5 2008 "P2503,P2504,P2505,P2599" 5 2009 "P2504,P2515,P2599" end
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(id year P2503 P2504 P2505 P2515 P2599) 4 2010 1 . . 1 1 4 2011 1 1 1 . . 5 2008 1 1 1 . 1 5 2009 . 1 . 1 1 end
Comment