BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Tom
Super User Tom
Super User

SAS created two complementary macros for dealing with the extended xport format files. %XPT2LOC() and %LOC2XPT().

https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/movefile/p1x39mw5fqqnyln1a08o7tomv47e.htm

 

The both support copying multiple datasets into/out of a single transport file.  Just leave off the optional MEMLIST parameter and it will copy all members from the libref into the transport file.  Or all members from the transport file to the libref.

 

PS Be careful with empty datasets as there was (still is?) a bug in %XPT2LOC() where it was unable to notice when an empty file ended which caused it to read the information about the next file as data for the file that should have had zero observations.

Ksharp
Super User
Follow the @Tom suggestion . There is another macro can do this . Same as

filename xpt 'Z:\Databases\CDM\Exports\Production\20220408_Test\Export\Results\xyz.xpt';
libname sas v9 'Z:\Databases\CDM\Exports\Production\20220408_Test\Export\Input';

%xpt2loc(libref=sas,filespec=xpt)
A_Kh
Lapis Lazuli | Level 10

Hi @Ksharp,

 

Thank you for sharing the information. I couldn't create .xpt using the V8 version due to syntax issiues. I use the server SAS, not installed in my laptop c disk. 

 

Would you please give me the syntax for converting following dataset into .xpt using V8 xport engine?
 dataset= "xyz.7bdat" need to be converted "xyz.xpt"

input_folder = "Z:\Databases\CDM\Exports\Production\20220408_Test\Export\Input"

output_folder = "Z:\Databases\CDM\Exports\Production\20220408_Test\Export\Results"

Used the below syntax which did not work. 

 

FILENAME xpt "&output\xyz.xpt"; *output path and output file name;
LIBNAME SAS V9 "c:\temp\SAS";
%loc2xpt(libref=sas,filespec=xpt);

PROC COPY IN=result OUT=XPT;  *result= Input_folder;
	SELECTxyz/MEMTYPE=DATA;
RUN;

 

Ksharp
Super User
filename xpt 'Z:\Databases\CDM\Exports\Production\20220408_Test\Export\Results\xyz.xpt';
libname sas v9 'Z:\Databases\CDM\Exports\Production\20220408_Test\Export\Input';

%loc2xpt(libref=sas,filespec=xpt)

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

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
  • 18 replies
  • 3735 views
  • 4 likes
  • 6 in conversation