Is there a way to get the folder tree of my SASFolders in my command prompt?
What exactly does SASFolders indicate?
Folders that the library refers to?
What is the environment?
By command prompt, do you mean SAS for Windows?
Do you mean you want to get it in SAS, or just a pure command prompt, without starting SAS?
Be careful with your wording. SASFolders is usually associated with the internal folder structure of SAS metadata ("Folders" in Management Console).
What you mean is the filesystem structure.
With Windows, I would use the dir command with the proper options in a FILENAME PIPE and read the results with a data step.
If XCMD is not enabled, here's a piece of code by @Tom that recursively reads a directory tree with pure SAS means:
data filelist;
length dname filename $256 dir level 8 lastmod size 8;
format lastmod datetime20.;
input dname;
retain filename ' ' level 0 dir 1;
cards4;
/folders/myfolders
;;;;
data filelist;
modify filelist;
rc1=filename('tmp',catx('/',dname,filename));
rc2=dopen('tmp');
dir = not not rc2;
if not dir then do;
fid=fopen('tmp','i',0,'b');
lastmod=input(finfo(fid,foptname(fid,5)),NLDATM100.);
size=input(finfo(fid,foptname(fid,6)),32.);
fid=fclose(fid);
end;
else do;
dname=catx('/',dname,filename);
filename=' ';
lastmod=input(dinfo(rc2,doptname(rc2,5)),NLDATM100.);
end;
replace;
if dir;
level=level+1;
do i=1 to dnum(rc2);
filename=dread(rc2,i);
output;
end;
rc3=dclose(rc2);
run;
Insert the path(s) to be searched in the datalines.
The code as posted is for demonstration purposes so that it works in University Edition, but it can be applied to any environment that runs on a hierarchical filesystem (UNIX and Windows).
@AK100 wrote:
Well I need to know where my files resist. Is there a short way to check that?
Which files?
Data sets?
Programs?
Macros?
Reports?
Templates?
Options?
SAS Executable?
SAS Configuration?
Lots of different types of files and some of these are easy to get to in the metadata SAS maintains and others require using operating system tools. Specificity in need leads to better targeted responses.
The following code is a quick example.
cd "C:\Program Files\SASHome2"
rem all sasfiles
dir /s /b | findstr /i /R "\.sas" >c:\temp\sasdir.txt rem all directories and sasfiles tree /f | findstr /I /R "─ \.sas" >c:\temp\sastree.txt
That is for command prompt.
So save as .cmd or .bat and double click to start.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.