BookmarkSubscribeRSS Feed
shivasomaram
Calcite | Level 5

I have a list of .xpt files with me. The problem is that I cannot get from the transport file creator about typically what kind of procedure ( either XPORT or CPORT ) he/she used in the program. Is there a way that I can identify this and correspondingly use the PROC COPY or PROC CIMPORT procedure to extract the datasets from the transport files. I'm using SAS 9.4.

Any help with this is greatly appreciated.

1 REPLY 1
Tom
Super User Tom
Super User

Read the first few characters and check.

libname x xport 'test/class.xpt' ;

proc copy inlib=sashelp outlib=x ; select class; run;

libname x clear;

proc cport data=sashelp.class file='test/class.stc' ; run;

proc export data=sashelp.class file='test/class.csv' dbms=dlm replace;

delimiter=',';

run;

data fnames ;

  infile 'ls test/class.*' pipe truncover;

  input fname $200. ;

run;

data test;

  set fnames ;

  filename=fname ;

  infile xpt filevar=filename end=eof recfm=n ;

  if not eof then input prefix $char10. ;

  if prefix='HEADER REC' then type='XPORT' ;

  else if prefix='**COMPRESS' then type='CPORT';

  else type='UNKN' ;

  put type= prefix= :$quote. fname = :$quote. ;

run;

type=UNKN prefix="Name,Sex,A" fname="test/class.csv"

type=CPORT prefix="**COMPRESS" fname="test/class.stc"

type=XPORT prefix="HEADER REC" fname="test/class.xpt"

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 1187 views
  • 1 like
  • 2 in conversation