SAS Across Platform Data

Suppose you need to move your SAS data files from from UNIX to your PC. SAS data files can be easily moved from one operating system to another as long as they are written in a transportable format. You can create SAS transport files using the SAS XPORT engine or the CPORT procedure.

The following is a program to read a SAS XPORT file and then write it out as a regular SAS data file in UNIX.

* (1) Use the first LIBNAME statement to indicate the *
* SAS data file that you will be reading. *
* Place the name of your SAS data file in quotes. *
* Use the XPORT engine to indicate that the file *
* is save in transport format. *;

libname in xport 'mydata.xport';

* (2) Use the second LIBNAME statement to indicate the *
* location where you will create the new SAS data file. *
* Place the name of the directory in quotes. *
* A period ('.') represents the current working directory. *;

libname out '.';

* (3) Use the SET statement to read the old data file, *
* and use the DATA statement to write the new data file. *
* Notice that the "in" and "out" librefs are the same as *
* those assigned in the LIBNAME statements above. *
* The new data file will be saved as "newdata.ssd01." *;

data out.newdata;
set in.olddata;

You must make sure that the file name in the data step corresponds to the INTERNAL file name. Even though SAS data files are binary files, it's possible to look at the beginning of the dataset to find the internal dataset name (in case you don't know what name was used when the data set was created). You can also use the CONTENTS procedure in SAS to list the names of data files.

SAS transport files are stored in binary format. The "binary" mode must be invoked if you use FTP (File Transfer Protocol) to copy the files from one computer to another.

You may also want to try using DBMS/Copy to convert and transfer your files.

Page tags: data sas transport
page_revision: 0, last_edited: 1193768798|%e %b %Y, %H:%M %Z (%O ago)
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License