- clear
- input long Stkcd int year long ViolationID double Penalty str23 PunishmentType
- 405 1997 401656 500000 "2602,2604"
- 405 1998 401656 500000 "2602,2604"
- 405 1999 401656 500000 "2602,2604"
- 405 2000 401656 500000 "2602,2604"
- 407 2009 40340 . "2699"
- 407 2010 40340 . "2699"
- 407 2011 40340 . "2699"
- 407 2011 401329 . "2699"
- 407 2012 401329 . "2699"
- 408 2017 4084118 . "2603"
- 408 2017 4067625 600000 "2602,2604,2699"
- 408 2018 4084118 . "2603"
- 408 2018 4067625 600000 "2602,2604,2699"
- 408 2019 4067625 600000 "2602,2604,2699"
- end
希望得到的结果:
变量PunishmentType中,一个格子内包含了多个样本,希望将其进行拆分,并从wide变成long的形式。
本人使用的命令是:
- split PunishmentType ,parse(,) gen(x)
- destring x*,replace
- drop PunishmentType
- reshape long x,i ( ViolationID)
- drop if x== .
- rename x PunishmentType
- drop _j
但结果是系统提示id变量不唯一,本人不知道问题出在哪里,求各位老师指教


雷达卡







京公网安备 11010802022788号







