**tolong**, a faster implementation of

**reshape long**, is now available on ssc.

Type

**ssc install tolong**and afterwards

**help tolong**for details.

The syntax is sightly different from

**reshape long**as

**tolong**supports three kinds of stubnames

# matches numeric j

@ matches string j

* matches both string and numeric j

thus

**tolong x**is equivalent to

**reshape long x**

**tolong x#**is equivalent to

**reshape long x@**

**tolong x***is equivalent to

**reshape long x@, string**

**tolong x@**has no

**reshape long**equivalent

**tolong**also supports renaming on-the-fly as in

tolong height = h* weight = w*

**tolong**compares favorably in terms of speed against the user-written

**fastreshape**,

**sreshape**, and

**greshape**. The timings below were run in Stata/MP4.

Code:

1,000,000 observations (1) reshaping numeric a1-a9 b1-b9 c1-c9 d1-d9 (2) reshaping numeric a1-a9 b1-b9 c1-c9 d1-d9 and string e1-e9 f1-f9 (3) reshaping numeric a1-a9 b1-b9 c1-c7 d1-d2 (4) reshaping numeric a1-a9 b1-b9 c1-c7 d1-d2 and string e1-e6 f1-f3 command (1) (2) (3) (4) ---------------------------------------------- reshape long 18.91 26.51 15.71 21.45 fastreshape 9.58 11.07 + + sreshape 10.45 12.50 9.64 11.29 greshape 1.50 2.54 1.57 3.80 tolong 1.59 5.34 1.61 2.41 ---------------------------------------------- + fastreshape does not support unbalanced j

are constant within id.

Code:

command (1) (2) (3) (4) ---------------------------------------------- reshape long 37.51 51.85 38.22 46.20 fastreshape 19.15 21.18 + + sreshape 14.80 17.52 13.97 16.62 greshape 7.17 7.50 7.13 7.53 tolong 2.35 6.27 2.66 5.08 ---------------------------------------------- + fastreshape does not support unbalanced j

Code:

(1) reshaping numeric x1-x10000 (2) reshaping numeric x1-x100000 command (1) (2) -------------------------------- reshape long 77.12 + fastreshape 29.72 2916.03 sreshape * * greshape 7.04 ^ tolong 0.03 0.54 -------------------------------- + "variable _j takes on too many values" error * "invalid numlist has too many elements" error ^ "characteristic contents too long" error

## Comment