BookmarkSubscribeRSS Feed
abhinayingole
Obsidian | Level 7

Hi ,

  I wanted to know, what all the xpt files (only) available in the particular library.

  anyone know how to find it.

 

Thanks,

Abhinay

 

3 REPLIES 3
yabwon
Onyx | Level 15

Use the BasePlus package and the %dirsAndFiles() macro

 

For example like this:

%dirsAndFiles(
C:\SAS_WORK /* directory to search (includes subdirs.) */
,ODS=work.result
,fileExt=xpt /* file extension */
)

Bart

 

P.S. Here are some instructions how to get BasePlus package and where the documentation is.

/*
Details about SAS Packages Framework:
- https://github.com/yabwon/SAS_PACKAGES

Tutorial:
- https://github.com/yabwon/HoW-SASPackages

BasePlus documentation:
- https://github.com/SASPAC/macroarray/blob/main/baseplus.md
*/

/* Step 1. */
/* Install SAS Packages Framework and BasePlus package. */
/* Run this only once. */
filename SPFinit url "https://bit.ly/SPFinit";
%include SPFinit; 
filename SPFinit clear;

/* create directory for the framework and packages */
filename packages "</your/directory/for/packages/>";
/* install the framework and the BasePlus package */ 
%installPackage(SPFinit BasePlus)


/* Step 2. */
/* From now on if you want to use a package: */
/* Run this at the beginning of your new SAS Session (or add it to autoexec). */
/* Enable framework and load package  */
filename packages "</your/directory/for/packages/>";
%include packages(SPFinit.sas); 
%loadPackage(BasePlus)

 

 

_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug

"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings

SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation



s_lassen
Meteorite | Level 14

I think you can use the SAS directory functions to list the files, e.g.:

data ExportFiles; 
   rc=filename("mydir", "<physical file name>"); 
   did=dopen("mydir"); 
   if did > 0 then do;
     do _N_=1 to dnum(did); 
       fname=dread(did,_N_);
       if upcase(scan(fname,-1,'.')) = 'XPT' then output;
       end;
     rc=dclose(did);
     end; 
   else do; 
     msg=sysmsg(); 
     put msg; 
     end;
   keep fname;
run;
Tom
Super User Tom
Super User

What do you mean by LIBRARY?

In SAS you can use the LIBNAME statement to make a library to points to where SAS datasets and other SAS objects are stored.

 

But an XPT file is NOT a SAS object that would be stored in such a library.

 

If you mean a directory of files (what some call a "folder") then just use normal tools for listing the files in a directory.  This question has been asked many times.  Here is one: https://communities.sas.com/t5/SAS-Programming/SAS-Macro-to-Check-Each-Subfolder-Within-a-Directory-...

 

Note that you will also need to take care once you have the list of XPT files as that extension has no fixed meaning.  It could be a SAS V5 Xport file produced by the XPORT libref engine.  It could be a transport file produced by PROC CPORT.  It could be a SAS V7/8/9 Xport file produced by the %LOC2XPT() system macro.  Or could be something that is not at all related to SAS.

 

sas-innovate-wordmark-2025-midnight.png

Register Today!

Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.


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
  • 3 replies
  • 874 views
  • 2 likes
  • 4 in conversation