Search notes:

SAS statements: infile

The infile statement identifies an external data file or an in-stream data from which data should be read. With the infile statement, the data is described in a way that it can be processed by SAS.
When SAS encounters the statement, it opens the file and creates the needed input buffer.
INFILE file-specification <option(s)>;
The file-specification is either a filename (such as /home/tq84/foo.dat), a fileref, an alias or a ddname.
After opening the file, the data can be read with the input statement.

Specifying the filename

The filename of the file to be read can be specified with the infile statement:
data tq84_ts; 

 infile 'c:\path\to\file.dat';

 input
   num
   en  $
   ge  $
 ;

run;

proc print data=tq84_ts;
run;
Github repository about-SAS, path: /programming/statements/infile/filename.sas
Instead of a operating system path, a fileref can be used.

delimiter

The default delimiters are spaces (blanks). The delimiter option (apparently abbreviated with dlm) changes the delimiter
/*

  Use delimiter option of infile to read data that is
  separated by commas rather than by blanks.

*/

data tq84_ts; 
  infile datalines delimiter=',';
  input      x y;
  z = x+y;
datalines;
1,5
4,9
3,0
2,5
;
Github repository about-SAS, path: /programming/statements/infile/delimiter.sas

dsd - delimiter sensitive data

data tq84_dsd;
  infile datalines dsd;

  length bar $ 50;

  input
    foo
    bar $
    baz $
  ;

datalines;
1,one,I
  5  ,  five , V
 100 , "one hundred and one", C
 104,"one hundred and four"  , CIV
;


proc print data = tq84_dsd;
run;
Github repository about-SAS, path: /programming/statements/infile/dsd.sas

See also

SAS statements

Index