https://twitter.com/johannesmboehm/s...48146396504064 raised a question about fillin. As tweets may disappear for various reasons, here it is, edited slightly.

fillin doesn't allow by: (but never understood why). I just wish there was a more efficient way to do it rather than reshaping twice.
The reason is, as I understand it, that the variables you want to specify in by: can just be specified directly.

Here is a silly example, a panel dataset that you want to make balanced (futile though that may be):

Code:
* Example generated by -dataex-. To install: ssc install dataex
clear
input float(AreaID Year Var1 Var2)
1 2000 20 30
1 2001 21 32
2 2000 50 55
end

fillin AreaID Year

list

+---------------------------------------+
| AreaID Year Var1 Var2 _fillin |
|---------------------------------------|
1. | 1 2000 20 30 0 |
2. | 1 2001 21 32 0 |
3. | 2 2000 50 55 0 |
4. | 2 2001 . . 1 |
+---------------------------------------+