Reading Raw Data |
Referencing a Raw Data
File |
Using a FILENAME Statement
Before you can read your raw data, you must point to the location of the external file containing the data. In the lesson Working in the SAS Environment, you learned to define file references (filerefs) by using file shortcuts. You can also define filerefs using a FILENAME statement. |
To do this... | Use this SAS statement... |
Reference SAS data library | |
Reference external file | FILENAME statement |
In the same way that you assign a libref by using a LIBNAME
statement, you assign a fileref by using a FILENAME statement.
Filerefs perform the same function as librefs: they temporarily point to a storage location for data, but librefs reference SAS data libraries while filerefs reference external files. |
You use a FILENAME statement to assign a fileref to an external file. |
General form, FILENAME statement:
where fileref is a valid SAS name that you associate with an external file and 'filename' is the fully qualified name or location of the file. |
This FILENAME statement temporarily associates the fileref
Tests with the external file that contains the readings
from the exercise stress tests. The file is located in
C:\Users\tmill.dat in the Windows environment.
filename tests 'c:\users\tmill.dat'; |
Raw Data File Tests
1---+----10---+----20---+----30---+----40---+--
2458 Murray, W 72 185 128 12 38 D
2462 Almers, C 68 171 133 10 5 I
2501 Bonaventure, T 78 177 139 11 13 I
2523 Johnson, R 69 162 114 9 42 S
2539 LaMance, K 75 168 141 11 46 D
2552 Reberson, P 69 158 139 15 41 D
You can also use a FILENAME statement to associate a fileref with an aggregate storage location, such as a directory that contains a number of external files. |
This FILENAME statement temporarily associates the fileref
Finance with the directory
C:\Users\Personal\Finances:
filename finance 'c:\users\personal\finances'; |
Both the LIBNAME and FILENAME statements are global. In other words, they remain in effect until you change them, cancel them, or end your SAS session. |
Copyright © 2002 SAS Institute Inc.,
Cary, NC, USA. All rights reserved.