|
SAS CornerBy Dr. Karl Ho, Research and Statistical Support Services ManagerData Capability: Data EnginesIn the previous two articles, I wrote about how SAS reads OSIRIS data and moves mainframe data to other platforms. In this article, I briefly introduce SAS' data capability in reading and converting data from and to other formats such as SPSS and Excel. The key to opening doors to these other data products is called engines. SAS engines are "sets of internal instructions that SAS uses to read from and write to files". The engine identifies the set of routines that the SAS System uses to access the files in the data library. With this architecture, data can reside in different types of files, including SAS data files and data formatted by other software products, such as SPSS, BMDP and other database management systems. For SAS data files, native library engines can be used to access data generated in different versions. Examples are V8 (current), V7 and V6. An XPORT engine is also available for converting all versions of data to transport files for moving to other platforms. For other formats, SAS handles them using data I/O engines, which "interface" data from SAS to other format or the other way around. You can specify engine types in the libname statement: LIBNAME LIFREF engine "path\(filename)"; By default, if no engine type is specified, the V8 BASE engine is used. Note that when the native library engine is used (V8, V7 or V6 except XPORT), the path is the directory is specified (e.g. c:\temp; \usr\data\). But when used with the I/O or XPORT engines, you need to specify the filename with full path (e.g. c:\temp\country.por; \usr\data\country.dat). We have discussed earlier the use of the OSIRIS engine for reading in mainframe OSIRIS data into SAS. I will give some more examples in this article on the SPSS and XPORT engines. Reading SPSS data The SPSS engine is designed for reading in SPSS portable data directly into SAS without transformation. This can also be achieved by using the PROC CONVERT procedure: The same two programs can be used for reading BMDP data, just by changing the engine and file names. XPORT engine This special engine is designed to convert SAS data to transport file format that can be used for moving data to other platforms or statistical package. The syntax is: libname source 'c:\DATA'; where TEST is the SAS data file under the SOURCE library and the new transport file, COUNTRY.TRANSPORT will be created under C:\TEMP. PROC EXPORT There is another procedure that performs similar functions. PROC EXPORT converts SAS data into such other formats as Excel or Lotus spreadsheet, MS Access table or delimited data file. The following sample program converts a SAS data set into a tab-delimited data file c:\temp\test2.txt. proc export data=test outfile='c:\temp\test2.txt' replace dbms=tab;
|