BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Ryanb2
Quartz | Level 8

I had been using the code below and do some parsing to create an inventory of the contents of a folder and subfolders including path, name of file, file extension, date modified, time modified, and file size.  However, our IT department is taking away our ability to use the ls command inside Viya making this code obsolete.

 

	filename pipedir pipe %sysfunc(quote(ls -lR --full-time "&pathDir" )) lrecl=1000;
	data DIR_RAW;
		infile pipedir truncover;
		input line $char1000.;
	run;

I was directed to other SAS options such as data information functions (Paper Template (lexjansen.com) but from what I can tell they're pretty limited.  For example, I can get the filename but not the path if the file is in a sub-folder.  I also can't seem to find a way to get the date modified, time modified, or file size.  

 

If I only needed to inventory SAS datasets then I could use proc datasets (SAS Help Center: Requesting a Directory Listing for a SAS Library) to get most of the information I need, but I need all file types.  It also doesn't seem to include sub-folders.

 

Any ideas?  Using SAS Viya V.03.05M0P111119

 

 

1 ACCEPTED SOLUTION
4 REPLIES 4
yabwon
Onyx | Level 15

I'd recommend using the BasePlus package, in particular the %dirsandfiles() macro. The macro gives you the list of files and sub-directories (with content) plus all that "metadata" stuff. It works OS independent, so on Win/Linux/UNIX. 

 

This article, Appendix B, page 20, gives you quick instruction on how to install and use the package.

 

Bart

 

 

_______________
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



yabwon
Onyx | Level 15
Kurt, the macro I mentioned essentially uses your paper code (plus add some additional features to it). I'm even attaching your article to the package.

Bart
_______________
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



sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

Discussion stats
  • 4 replies
  • 1644 views
  • 5 likes
  • 4 in conversation