Using the INFILE statement

Senast ändrad: 10 februari 2021

A combination of using an external file but still reading data using a SAS program is to use the infile statement. This is useful if you need to read several files with the same structure to SAS. The easiest way is to first convert your files to comma seperated files (csv) or text files.

Below the data set 'observed_values.csv' is available in the directory 'Z:\SAS\data\'.

data indata1;
infile 'Z:\SAS\data\observed_values.csv' dlm=','  firstobs=2 ;
input date :anydtdte20. type $ concent;



We use dlm=',' to indicate that we have comma (,) as delimiter between the different variables. If we use a tab delimited file we use dlm='09'x

 firstobs=2 indicates that the program should read data from the second row only, since the first row contains headers.

The input statement is the same as when we read data from the editor