BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
zimcom
Pyrite | Level 9

I havew one single SAS Xport Transport File and I want to convert the file into SAS file so that I could open it in SAS, can someone let me know how to convert it? 

 

Is it possible that SAS Xport Transport File is the SAS program, not the SAS dataset? 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

SAS has two main types of "transport" files, each of which has some version specific variation.  The XPT format could be used for either type so you will just need to try both methods and hope one works.

 

The public published format is the transport file. The most common version is the original format from SAS Version 5 which has maximum length of 8 characters for names and maximum length of 200 characters for character variables. You can read those with the XPORT engine.  If the libname statement works you can either reference the members (datasets) in the transport file directly by name or just use PROC COPY to copy them out into another library. Like the WORK library of you current SAS session.

libname in xport "name of transport file";
proc copy inlib=in outlib=work;
run;

If you have the newer version 8 transport file then you need to use the macro that SAS provides for that.

 

The other format is the format produced by PROC CPORT.  What I tend to call CPORT files.  To generate that format you use PROC CPORT and to read it you use PROC CIMPORT.

proc cimport library=work infile="name of transport file";
run;

 

 

 

View solution in original post

5 REPLIES 5
Jagadishkatam
Amethyst | Level 16

Please try

 

 

libname xptfile xport '~path\sample.xpt' ;
libname sasfile '~path';
proc copy inlib=xptfile outlib=sasfile; run;
Thanks,
Jag
zimcom
Pyrite | Level 9

I got the message of the following:

WARNING: Input library XPTFILE is empty.

Tom
Super User Tom
Super User

@zimcom wrote:

I got the message of the following:

WARNING: Input library XPTFILE is empty.


Try reading it as a CPORT file instead.

If that doesn't work then check the file itself to see if it is in fact any type of SAS transport file.  Just look at the first few bytes of the file.

data _null_;
  infile "name of transport file" recfm=F lrecl=80 obs=1 ;
  input;
  list;
run;

Example:

303   options generic;
304   filename xport temp;
305   filename cport temp;
306   libname xport xport ;
NOTE: Libref XPORT was successfully assigned as follows:
      Engine:        XPORT
      Physical Name: (system-specific file/path name)
307   data xport.class; set sashelp.class; run;

NOTE: The data set XPORT.CLASS has 19 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds


308   proc cport library=sashelp file=cport;
309    select class;
310   run;


NOTE: PROC CPORT begins to transport data set SASHELP.CLASS
NOTE: The data set contains 5 variables and 19 observations.
      Logical record length is 40.
NOTE: PROCEDURE CPORT used (Total process time):
      real time           0.00 seconds
      cpu time            0.01 seconds


311
312   data _null_;
313     infile xport recfm=F lrecl=80 obs=1;
314     input;
315     list;
316   run;

NOTE: The infile XPORT is:
      (system-specific pathname),
      (system-specific file attributes)

RULE:     ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+--
1         HEADER RECORD*******LIBRARY HEADER RECORD!!!!!!!000000000000000000000000000000
NOTE: 1 record was read from the infile (system-specific pathname).
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds


317
318   data _null_;
319     infile cport recfm=F lrecl=80 obs=1;
320     input;
321     list;
322   run;

NOTE: The infile CPORT is:
      (system-specific pathname),
      (system-specific file attributes)

RULE:     ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+--
1         **COMPRESSED** **COMPRESSED** **COMPRESSED** **COMPRESSED** **COMPRESSED********
NOTE: 1 record was read from the infile (system-specific pathname).
NOTE: DATA statement used (Total process time):
      real time           0.00 seconds
      cpu time            0.00 seconds


323   options nogeneric;
zimcom
Pyrite | Level 9

@Tom @Jagadishkatam 

A big THANK YOU to both of you!

Tom
Super User Tom
Super User

SAS has two main types of "transport" files, each of which has some version specific variation.  The XPT format could be used for either type so you will just need to try both methods and hope one works.

 

The public published format is the transport file. The most common version is the original format from SAS Version 5 which has maximum length of 8 characters for names and maximum length of 200 characters for character variables. You can read those with the XPORT engine.  If the libname statement works you can either reference the members (datasets) in the transport file directly by name or just use PROC COPY to copy them out into another library. Like the WORK library of you current SAS session.

libname in xport "name of transport file";
proc copy inlib=in outlib=work;
run;

If you have the newer version 8 transport file then you need to use the macro that SAS provides for that.

 

The other format is the format produced by PROC CPORT.  What I tend to call CPORT files.  To generate that format you use PROC CPORT and to read it you use PROC CIMPORT.

proc cimport library=work infile="name of transport file";
run;

 

 

 

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 20549 views
  • 2 likes
  • 3 in conversation