Help using Base SAS procedures

How to identify the kind of procedure used for creating a SAS transport file ?

Reply
New Contributor
Posts: 4

How to identify the kind of procedure used for creating a SAS transport file ?

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.

Super User
Super User
Posts: 6,500

Re: How to identify the kind of procedure used for creating a SAS transport file ?

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"

Ask a Question
Discussion stats
  • 1 reply
  • 192 views
  • 1 like
  • 2 in conversation