![]() Chapter Contents |
![]() Previous |
![]() Next |
| CALL SYSTEM |
| OS/2 specifics: | command must be a valid OS/2 command |
| Syntax | |
| Details | |
| Comparison | |
| Examples | |
| Example 1: Executing Operating System Commands Conditionally | |
| Example 2: Obtaining a Directory Listing | |
| See Also | |
Syntax |
| CALL SYSTEM(command) |
| Details |
If you are running SAS interactively and the command that you run is an OS/2-based command or program, the command executes in a
command prompt window. By default, you must type
exit to return to your SAS session.
| Comparison |
The CALL SYSTEM routine is similar to the X command. However, the CALL SYSTEM routine is callable and can therefore be executed conditionally. An example of using the CALL SYSTEM routine is given in Executing Operating Environment Commands Conditionally.
The values of the XSYNC and XWAIT system options affect how the CALL SYSTEM routine works. For more information about these options, see XSYNC and XWAIT.
| Examples |
If you want to execute operating system commands conditionally, use the CALL SYSTEM routine:
options noxwait;
data _null_;
input flag $ name $8.;
if upcase(flag)='Y' then
do;
command='md c:\'||name;
call system(command);
end;
cards;
Y mydir
Y junk2
N mydir2
Y xyz
;
This example uses the value of the variable FLAG to conditionally create directories. After the DATA step executes, three directories have been created: C:\MYDIR,
C:\JUNK2, and C:\XYZ. The directory C:\MYDIR2 is not created because the value of FLAG for that observation is not
Y.
data _null_;
answer='n';
if upcase(answer)='y' then
do;
x 'md c:\extra';
end;
run;
In this case, the directory C:\EXTRA is created regardless of whether the value of ANSWER is equal to
'n' or
'y'.
The following is an example of using the CALL SYSTEM routine to obtain a directory listing:
data _null_;
call system('dir /w');
run;
| See Also |
![]() Chapter Contents |
![]() Previous |
![]() Next |
![]() Top of Page |
Copyright © 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.