China Health and Nutrition Survey


You Are Here: CHNS Home > Survey Data > Documentation > Using SAS XPORT Files


Using SAS XPORT Files

Consider the following problem. Your colleague, who works on a unix computer, creates a data set that you need to use on your personal computer. You could use FTP to move the file from unix to your PC, but what about the fact that the two machines store data differently?

SAS answered this problem by providing an XPORT engine to allow data sets to be moved across platforms. Data stored in XPORT format can be analyzed in SAS on any platform for which SAS is available. In other words, if your colleague had stored her data in SAS XPORT format on her mainframe, then you could simply FTP the data to your PC and use PC-SAS to analyze the data.

The obvious appeal of this file format led us to choose it as our file format for the CHNS data. It allows us to store the data on our host machine in a single format, without regard to the environment in which you, the user, operate.

If you are not a SAS user, you will find that many other applications, such as SPSS, can read SAS XPORT files. Consult the documentation for your particular software for details. If your software cannot read SAS XPORT files directly, a conversion software program, such as dbms/copy, can convert SAS XPORT files to a wide variety of file formats.

If you are a SAS user, and you are unfamiliar with SAS XPORT files, then you would probably like some examples of SAS statements that process SAS XPORT files. As always, the best source for such information are the manuals themselves--try the SAS Language Reference. For those of you without access to manuals, we have included some sample code below. Incorporate the following into your code to turn a SAS XPORT file into a file in native engine format.

An important feature of the XPORT engine is the concept of members. Just like a SAS data set is a member of a SAS library (often a sub-directory), XPORT data sets have members. Although an XPORT file usually has only one member, it is important not to forget the member name of the data set.

When declaring an XPORT library reference, the libname statement actually points to a file which contains a single member: the XPORT data set. It is necessary to know the member name of the data set, since it may differ from the name of the file that is referenced in the library reference. In the examples below, all member names are alpha, but in the data you will FTP from us, the member name is the same as the file name. Even though the name is the same, it must still be repeated in the data step portion of your program.

Unix Example

/**Notice that the entire filename is specified in the libname statement**/
/**Unlike a normal filename in which only the path is specified        **/
libname in xport '/your/file/system/data/c89hh1.0896.xpt';
data one;
   set in.alpha;
run;

Windows Example

libname in xport 'c:\webdata\chns\c89hh1.0896.xpt';
data one;
   set in.alpha;
run;

MVS Example

//*JCL STATEMENTS
// EXEC SAS
//IN DD DSN=C89HH1.0896.XPT,DISP=OLD
LIBNAME IN XPORT;
DATA ONE;
   SET IN.ALPHA;
RUN;

UNC Carolina Population Center

Last Modified: 10/18/2004
Login