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;

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

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
  • 1076 views
  • 0 likes
  • 2 in conversation