Refactorizations:
- Simplified loops
- Fixed initialization order in StataWriter constructor
- Avoid temporary variable
- Fixed arguments passed to StataWriter in tests