- About CISER Computing
- Computing Resources
- Request a CISER Computing Account
- Computing Node Availability and Usage
- Computing News & User Notes
- HelpDesk Services
- CISER Computing Basics
- CISER Computing FAQ
- Workshop Downloads
- Workshop Schedules & Registration
- Software on the Computing Nodes
- Online Help for Statistical Software
- Buying Statistical Software at Cornell
Reading Multiple Raw Data Files
Q. Can I read multiple raw data files in a DATA step to create a combined SAS data set, all my files have the same data layout?
A. If a number of raw data files have the same data layout, all of those files can be included in a FILENAME statement and assigned a single fileref. When this fileref is included in a Data step, SAS can read those input raw data files sequentially.
For example, some of the census data have a separate raw data file for each state, all state files have a similar data layout. To create a combined SAS data set for US, the raw data files can be included in a FILENAME statement to be read in a Data step. Here is an example.
FILENAME myfiles ("c:\mydir\one.dat", "c:\mydir\two.dat", "c:\mydir\three.dat");
DATA temp1;
INFILE myfiles lrecl=331;
INPUT var1 10-15 var2 22-30 var3 98-100;
RUN;
With SAS 8.2 you can also use wildcards in your FILENAME statement like this:
filename myfiles ("c:\mydir\*.csv");
filename myfiles ("c:\mydir\test*.dat");
filename myfiles ("c:\mydir\*.*");