In reply to Jim Barbour.

Thanks, Jim. As I say in the second section, you don't even need the macro in modern versions of SAS. Just use rand("Integer", 1, 10); That should work from anywhere that you can call Base SAS functions (FCMP, WHERE clauses, etc)