SAS OnlineTutor HomeFAQ PageSuggested Learning PathsContents+Searchback||next

Reading Raw Data
Writing the DATA Step Program


Specifying the Raw Data File

When reading raw data, use the INFILE statement to indicate which file the data is in.


To do this...   Use this SAS statement...
Reference SAS data librarylibname clinic 'c:\users\may\data';
Reference external filefilename tests 'c:\users\tmill.dat';
Name SAS data setdata clinic.stress;
Identify external fileINFILE statement  


General form, INFILE statement:
INFILE file-specification <options>;

where file-specification can take the form fileref to name a previously defined file reference or 'filename' to point to the actual name and location of the file.


Adding the OBS= option to the INFILE statement enables you to process only through record n, so you can verify that the correct fields are being read before reading the entire data file.

To specify that the raw data file assigned the fileref Census be read, you write the following INFILE statement:

     infile census obs=5;

Note that instead of using a FILENAME statement, you can choose to identify the raw data file by specifying the entire name and location in the INFILE statement. For example, the following statement points directly to the C:\Irs\Personal\refund.dat file:

     infile 'c:\irs\personal\refund.dat';


back||next


Copyright © 2002 SAS Institute Inc., Cary, NC, USA. All rights reserved.

Terms of Use & Legal Information | Privacy Statement