Working with External Files


Reading External Files

The primary reason for reading an external file in a SAS job is to create a SAS data set from raw data. This topic is covered in Chapter 21, 'Reading Raw Data,' on page 357.

Writing to External Files

You can write to an external file by using:

  • a SAS DATA step

  • the External File Interface (EFI)

  • the Export Wizard.

When you use a DATA step to write a customized report, you write it to an external file. In its simplest form, a DATA step that writes a report looks like this:

 data _null_;     set budget;     file '  your-file-name'  ;     put  variables-and-text  ;  run; 

For examples of writing reports with a DATA step, see Chapter 21, 'Reading Raw Data,' on page 357.

If your operating environment supports a graphical user interface, you can use the EFI or the Export Wizard to write to an external file. The EFI is a point-and-click graphical interface that you can use to read and write data that is not in SAS internal format. By using the EFI, you can read data from a SAS data set and write it to an external file, and you can read data from an external file and write it to a SAS data set. See the SAS online Help for more information on the EFI.

The Export Wizard guides you through the steps to read data from a SAS data set and write it to an external file. As a wizard, it is a series of windows that present simple choices to guide you through the process. See the SAS online Help for more information on the wizard.

Processing External Files

When reading data from or to a file, you can also use a DATA step to:

  • copy only parts of each record to another file

  • copy a file and add fields to each record

  • process multiple files in the same way in a single DATA step

  • create a subset of a file

  • update an external file in place

  • write data to a file that can be read in different computer environments

  • correct errors in a file at the bit level.

For examples of using a DATA step to process external files, see Chapter 21, 'Reading Raw Data,' on page 357.




SAS 9.1 Language Reference. Concepts
SAS 9.1 Language Reference Concepts
ISBN: 1590471989
EAN: 2147483647
Year: 2004
Pages: 255

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net