I found this code for listing directories at:http://support.sas.com/kb/24/820.html
filename DIRLIST pipe 'dir "C:\Documents and Settings" /s';
data dirlist ;
length buffer $256 ;
infile dirlist length=reclen ;
input buffer $varying256. reclen ;
run ;
However I get the following error when I insert my path. I am using SAS UE so I am certain that I should have access to my folders.
Can someone tell me why this occurs and how to overcome the issue?
You can do it with SAS means:
data files (keep=fname);
rc = filename("mydir","/folders/myfolders");
did = dopen("mydir");
if did > 0
then do i = 1 to dnum(did);
fname = dread(did,i);
output;
end;
rc = dclose(did);
run;
Further SAS means (fopen, foptnum, foptname, finfo) can be used to retrieve details of files.
To be able to use filename pipe, XCMD needs to be enabled, which is not the case out-of-the-box in a SAS BI Server setup.
You need to ask your SAS administrator do enable this on the workspace server yo are using.
You can do it with SAS means:
data files (keep=fname);
rc = filename("mydir","/folders/myfolders");
did = dopen("mydir");
if did > 0
then do i = 1 to dnum(did);
fname = dread(did,i);
output;
end;
rc = dclose(did);
run;
Further SAS means (fopen, foptnum, foptname, finfo) can be used to retrieve details of files.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.