The OUTTRAP function should trap output from the DSN command. OUTTRAP is designed to TRAP the OUTput of most TSO commands. Output is placed in a variable (normally a stem variable) that you supply. (Certain TSO commands cannot be trapped; this is discussed elsewhere in the TSO/E REXX Reference.)
Taking your code as supplied above, we can cobble together this:
ORC = OUTTRAP('O.') /* preserve prior setting of OUTTRAP */
QUEUE "-DIS DATABASE(*) SPACENAM(*) RESTRICT(CHKP,COPY)"
QUEUE "END"
ADDRESS TSO "DSN SYSTEM(DB2D)"
CALL OUTTRAP ORC /* restore OUTTRAP setting */
DO #O = 1 TO O.0 /* The 0 entry by convention has the number of records */
/* You can PARSE, analyze, or do whatever here */
SAY "O."'#O "='"O.#O"'" /* example */
END #O /* end the loop */
OUTTRAP is a very powerful function when writing scripts in TSO/E REXX.