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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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
  • 1 reply
  • 697 views
  • 1 like
  • 2 in conversation