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 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of 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
  • 817 views
  • 1 like
  • 2 in conversation