Using SAS/IML Software to Generate IML Statements |
Suppose that an interactive program gets responses from the statement INFILE CARDS. If you want to feed it under program control, you can push lines to the command stream that is read.
For example, suppose that a subroutine prompts a user to
respond YES
before performing some action.
If you want to run the subroutine and feed the YES
response
without the user being bothered, you push the response as follows:
/* the function that prompts the user */ start delall; file log; put 'Do you really want to delete all records? (yes/no)'; infile cards; input answer $; if upcase(answer)='YES' then do; delete all; purge; print "*** FROM DELALL: should see End of File (no records to list)"; list all; end; finish;The latter DO group is necessary so that the pushed
YES
is not read before the RUN statement.
The following example illustrates the
use of the preceding module DELALL:
/* Create a dummy data set for delall to delete records */ xnum = {1 2 3, 4 5 6, 7 8 0}; create dsnum1 from xnum; append from xnum; do; call push ('yes'); run delall; end;
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.