Reputation: 1759
I am trying to use the following code to list all file names with a prefix in a folder and call a function named CALCU with the filenames:
proc contents data=&libref.._all_ noprint out=contents; run;
data _null_;
set contents;
by memname;
if first.memname ;
if upcase(memname) =: %upcase("&prefix");
call execute(cats('%nrstr(%CALCU)(',memname,')'));
run;
The code works fine when I have complete authorized access to all of the files in the directory. But now I found out that I actually don't have some access to some of the files with certain prefixes (luckily, I don't actually need those files that I don't have access to).
However, SAS just keeps throwing out errors like
ERROR: User does not have appropriate authorization level for file
TAQ_CT.CTM_20120222.DATA.
Even though this is not the file I want.
I wonder how do I skip some of the files in the directory?
I have tried to delete everything else but the following line of code:
proc contents data=&libref.._all_ noprint out=contents; run;
Still, it seems that I cannot even read the content properly when I don't have access to all of the files (SAS just keeps throwing out errors on the files that I don't have access to).
Upvotes: 1
Views: 355
Reputation: 12465
I don't have a way to test this, but try SASHELP.VMEMBER
instead of PROC CONTENTS
data _null_;
set SASHELP.VMEMBER(where=(libname=upcase("&libref") and memtype = "DATA"));
if upcase(memname) =: %upcase("&prefix");
call execute(cats('%nrstr(%CALCU)(',memname,')'));
run;
This is a system view that lists all SAS files in a directory. This way, you only try to access the ones you want.
Upvotes: 1