🔒 This topic is solved and locked.
Need further help from the community? Please
sign in and ask a new question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 12-29-2019 08:29 AM
(4429 views)
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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.