You probably need to have some conformity in your programs before you think of doing that, such as standard program headers.
As for outputs (and inputs), if they are not described in the header but to be derived from the code, you need to think about parsing programs that contains macro code.
The easiest (only?) way is to parse logs rather than programs, with options such as MPRINT turned on.
Also have a look at PROC SCAPROC.