BookmarkSubscribeRSS Feed
sasikala
Obsidian | Level 7

Hi Experts,

We are updating our code to use xpt2loc macro to extract the V6 and V8 format xpt file.

Kindly help me with the below queries.

What is pros and cons of using xpt2loc macro?

Why libname xport is not supporting the V8 format xpt file which is created by loc2xpt macro?

What is the different in using xpt2loc macro and libname xport proc copy for extracting files?

Thanks,

Sasikala.k

1 REPLY 1
vellad
Obsidian | Level 7

You should find this paper helpful: https://support.sas.com/resources/papers/proceedings/proceedings/sugi23/Begtutor/p56.pdf

You can read the header line in transport files and use the correct macro, depending on the host environment where the xpt got created, something like this:

filename xptfile "&xpt";
libname sasfile "&sasds.";        
data _NULL_; 
    infile xptfile obs=1;
    input line $ASCII80. ;
    call symput('engine',line);
run;

%if %index(&engine,LIBV8) > 0 %then %do;
    %xpt2loc(libref=sasfile, filespec=xptfile);
%end;
%else %if %index(&engine,XPORT) > 0 %then %do;
    libname xptxport xport "&dsn" access=readonly;
    proc copy inlib=xptxport outlib=sasfile;
    run;                
%end;
%else %do;
    proc cimport infile=xptfile library=sasfile memtype=data;
    run;
%end;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

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

Browse our catalog!

Discussion stats
  • 1 reply
  • 1011 views
  • 0 likes
  • 2 in conversation