What is the difference between INFILE statement and PROC IMPORT statement and which one is better to use?
Difference between INFILE and PROC IMPORT
4.3k views Asked by akash singh AtThere are 2 answers
PROC IMPORT is a procedure. Like PROC MEANS or PROC PRINT. INFILE is a data step statement. Like INPUT, PUT, IF, etc.
You can use PROC IMPORT to convert data in various forms into SAS datasets. It can read from database files, spreadsheets and text files. It is really only for text files that there is any comparison with running your own DATA step (with an INFILE statement as one of the many statements in that step) that makes sense in this case.
If you use PROC IMPORT to read a delimited file then the procedure will make decisions about how to interpret the file. It will guess how many variables there are and what type to use for them. It will guess if any informats need to be used to properly read the text into data. It will convert the header line to variable names. Depending on the data it can sometimes work well and sometimes do really dumb things.
If you write your own DATA step then you have full control over what variables are created and how to read them. This might take a little more code or effort than letting a procedure guess for you. But if you have to read many similar files then using a data step will let you have the control needed to make sure that the individual datasets are created consistently.
as Tom speaked about difference between PROC Import and infile. Also infile supports libref but proc import doesnot. The proc import doesnot support statements for naming the variables name similar to data set. The names length types and other attributes are named automatically.