id x
1. A a
2. A b
3. A c
4. B d
5. B e
6. B f
7. B g
8. end
.
. bysort id: gen t=_n
. reshape wide x,i(id) j(t)
(note: j = 1 2 3 4)
Data long -> wide
-----------------------------------------------------------------------------
Number of obs. 7 -> 2
Number of variables 3 -> 5
j variable (4 values) t -> (dropped)
xij variables:
x -> x1 x2 ... x4
-----------------------------------------------------------------------------
. list
+------------------------+
| id x1 x2 x3 x4 |
|------------------------|
1. | A a b c |
2. | B d e f g |
+------------------------+