Amadeus cookies policy - you'll see this message only once.

Amadeus use cookies on this website. They help us to know a little bit about you and how you use our website, which improves the browsing experience and marketing - both for you and for others. They are stored locally on your computer or mobile device. To accept cookies, continue browsing as normal. Or, go to the privacy policy for more information.

Using the FILENAME PIPE Option to Run DOS Commands

Instead of using an X statement to submit operating system commands in Windows and Unix environments, consider using a FILENAME statement with the PIPE device.  The approach has two advantages over using the X statement:

  • In a Windows environment, there is no appearance of the DOS window.
  • The output from an operating system command can be read into SAS as if it were an ordinary external file.

The syntax is: FILENAME fileref PIPE ‘operating system command’;

Use a DATA step with an INFILE statement to submit the operating system command that is specified for the given Fileref.  To capture the output that results from the command’s execution, include an INPUT statement.

The following screen shot shows two examples of the FILENAME PIPE device being used.  The first one creates a new directory and the second one copies files into the new target directory:


The PUT statement writes the results from each command to the log, where _INFILE_ is an automatic DATA step variable which contains the contents of the input buffer.  The resulting log is as follows: