Monday, December 22, 2008

In SAS, how do I create a transport data set file?

In SAS, how do I create a transport data set file?

Source/direct link:http://kb.iu.edu/data/aevb.html

A SAS transport data set file is a machine-independent file that allows you to move a SAS data set from one operating system to another. A SAS transport data set file can also be read directly by several statistical software packages (e.g., SPSS, BMDP).

Following is an example of SAS code to copy the SAS data set file job1.sas7bdat to a SAS transport data set file portable.xpt in the outdata directory:

LIBNAME misc '~/work';
LIBNAME sasxpt XPORT '~/outdata/portable.xpt';


PROC COPY IN=misc OUT=sasxpt;

SELECT job1;
RUN;

In the example above:

The first LIBNAME statement aliases the library reference (libref) misc to the work directory.
The second LIBNAME statement aliases the libref sasxpt with the physical name of a SAS transport format file (in this case, portable.xpt in the outdata directory).

The COPY procedure copies one or more SAS data sets in the IN= libref (in this case, misc) to the OUT= libref (in this case, sasxpt).

The SELECT statement specifies that only the file job1.sas7bdat should be included in the transport file portable.xpt .

The file and pathnames in the above example follow Unix conventions. If you are using SAS for Windows, you should follow the appropriate filename and pathname conventions.

For example, in SAS for Windows, the two LIBNAME statements in the above example would instead be:

LIBNAME misc 'c:\work';
LIBNAME sasxpt XPORT 'c:\outdata\portable.xpt';




0 comments:

Post a Comment

ShareThis