BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jacksonan123
Lapis Lazuli | Level 10

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?

OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
72
73
74 filename DIRLIST pipe 'dir "folders/myfolders/aptensio_secalc/finalsas" /s';
ERROR: Insufficient authorization to access PIPE.
ERROR: Error in the FILENAME statement.
75
76 data dirlist ;
77 length buffer $256 ;
78
79 infile dirlist length=reclen ;
80
81 input buffer $varying256. reclen ;
82 run ;
 
ERROR: No logical assign for filename DIRLIST.
NOTE: The SAS System stopped processing this step because of errors.
WARNING: The data set WORK.DIRLIST may be incomplete. When this step was stopped there were 0 observations and 1 variables.
NOTE: DATA statement used (Total process time):
real time 0.02 seconds
cpu time 0.00 seconds
 
 
83
 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

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.

View solution in original post

3 REPLIES 3
Kurt_Bremser
Super User

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.

jacksonan123
Lapis Lazuli | Level 10
I am using SAS University edition so I guess the question is it possible to
enable XCMD with SAS UE in order to use filename pipe?

I looked on the help site at
https://communities.sas.com/t5/SAS-Procedures/How-to-enable-XCMD-in-SAS-Univ
ersity-Edition/td-p/265868 and it can't be done on SAS UE.

Thanks for your response.
Kurt_Bremser
Super User

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: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 3369 views
  • 1 like
  • 2 in conversation