.- help for ^fill^ (STB-43: dm55) .- Generating sequences and patterns of numeric data: an extension to egen ----------------------------------------------------------------------- A common task in Stata is the creation of repeating patterns and linear sequences of numeric data. The ^seq^ command of Cox (1997) makes this simple to do. ^fill^ is an extension to ^egen^ for creating sequences. ^fill()^ can create ascending or descending lists, including negative numbers and complex repeating patterns. Syntax ------ ^egen^ [type] varname ^= fill(^numlist^)^ ^fill()^ follows much the same syntax as many other ^egen^ functions. The numlist must contain only numeric values. Alphabetic characters are not supported. Options ------- There are no options associated with ^fill()^. Examples -------- To create a sequence of numbers, simply "show" ^fill()^ how the sequence should look. It must be a linear progression in order to produce the results you would expect. Geometric progressions are not understood. . ^egen i=fill(1 2)^ . ^egen x=fill(-10 -9)^ . ^egen y=fill(1 3 5)^ . ^egen z=fill(1 1 1 2 2 2)^ i x y z 1. 1 -10 1 1 2. 2 -9 3 1 3. 3 -8 5 1 4. 4 -7 7 2 5. 5 -6 9 2 6. 6 -5 11 2 7. 7 -4 13 3 8. 8 -3 15 3 9. 9 -2 17 3 10. 10 -1 19 4 11. 11 0 21 4 12. 12 1 23 4 13. 13 2 25 5 14. 14 3 27 5 15. 15 4 29 5 16. 16 5 31 6 17. 17 6 33 6 18. 18 7 35 6 19. 19 8 37 7 20. 20 9 39 7 To produce repeating patterns, you must create the pattern definition by repeating the pattern twice in the numlist. For example, to produce a pattern such as 1, 3, 2, 4, 1, 3, 2, 4 ... issue commands like . ^egen j=fill(1 3 2 4 1 3 2 4)^ . ^egen k=fill(-2 -1 0 1 2 -2 -1 0 1 2)^ . ^egen l=fill(1 1 2 2 1 1 2 2)^ . ^egen m=fill(0 0 1 0 0 1)^ j k l m 1. 1 -2 1 0 2. 3 -1 1 0 3. 2 0 2 1 4. 4 1 2 0 5. 1 2 1 0 6. 3 -2 1 1 7. 2 -1 2 0 8. 4 0 2 0 9. 1 1 1 1 10. 3 2 1 0 11. 2 -2 2 0 12. 4 -1 2 1 13. 1 0 1 0 14. 3 1 1 0 15. 2 2 2 1 16. 4 -2 2 0 17. 1 -1 1 0 18. 3 0 1 1 19. 2 1 2 0 20. 4 2 2 0 This is not a command one will likely use everyday, but in many circumstances ^fill()^ should make the generation of repeating sequences and patterns of numbers quite simple. In many cases, the ^fill()^ extension can be used in place of a ^generate^ command and complex expression using ^_n^ or ^_N^. Author ------ R. Mark Esman Stata Corporation Fax: 409-696-4601 mesman@@stata.com Reference --------- Cox, N. J. 1997. dm44: Sequences of integers. Stata Technical Bulletin 37: 2-4. Also see -------- STB: STB-43 dm55