12-19-2014 04:25 AM
Look at a example 3.3 in http://www.ats.ucla.edu/stat/sas/library/SASRead_os.htm
12-19-2014 04:56 AM
You need to clarify your question. Is the file you are dealing with:
XLS - I.e. Excel proprietary binary file (previous Excel version < 2007 have this a default) - This type of file cannot be read by methods other than proc import as it uses the JET engine.
XSLX - Excel native XML zipped file (current releases of Excel use this as standard now) - In theory you can unzip and read the individual XML files, not recommended though.
CSV - Comma Separated Variable file - this is a text file which can be parsed by Excel - Easy to read in an parse
Other - XML, text etc. - Easy to read in and parse.
Depending on the file type your code will change. Also bear in mind that using infile within a datastep and writing the import yourself is the preferred method, however you would be better served getting the file to CSV first (save as CSV in Excel).
12-19-2014 09:26 AM
What is your environment? Especially, on what platform is your base SAS running?
Is SAS/ACCESS to PC Files licensed?
You cannot use the INFILE statement of a data step directly for a .xls file, because Excel files are not structured in rows and colums on a physical level. Just a stream of bytes that needs to be decoded.
Even the import wizard in SAS Enterprise Guide does not read the .xls on its own, it relies on a piece of MS SW that does the decoding.
Do a web search for "Import Excel into SAS", there are tons of resources covering multitudes of methods, all having their pro's and con's.
12-19-2014 09:31 AM
You haven't mentioned why you want to use an input statement. An alternative way of reading Excel files is the libname access method. With it, you can do most of the things you'd typically like to accomplish with an input statement. Here are two links that describe it;