- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi ,
I wanted to know, what all the xpt files (only) available in the particular library.
anyone know how to find it.
Thanks,
Abhinay
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.