In reply to Reese Berry.

The second-to-last paragraph contains links to DATA step functions. You can also see the article "Lexicographic combinations."