shevaze 发表于 2013-4-22 13:28 
再请假一下哈,如果有A101a.A102a..但是还有B101a,B102a,那该怎么弄呢?
谢谢!
如果数据为如下形式
+----------------------------------------------------------+
| sampleid A101a A102a A103a B101a B102a B103a |
|----------------------------------------------------------|
1. | 1001 8 9 9 2 3 4 |
2. | 1002 1 9 9 5 6 7 |
+----------------------------------------------------------+
使用下面的代码可以满足你的需求。
--------------------begin myfile1.do--------------------
use temp, clear
reshape long @a, i(sampleid) j(id) string
gen positions = id+"a"
drop id
rename a direction
order sampleid positions direction
-------------------end myfile1.do----------------------