Dear community,
I have the following code but it gives me an error that I do not know how to fix. Please advise.
***************** CODE*********************
%macro impt(filename,i);
proc import DATAFILE="&filename" OUT=XL&i DBMS=XLSX REPLACE;
run;
%mend impt;
%let path = E:\Lev1\Data\1_INPUTDOCS\IMPDOC\;
data _null_;
command = "dir &path.*.xlsx /b";;
infile dummy pipe filevar=command end=eof truncover;
do i = 1 by 1 while(not eof);
input path $128.;
path=catt("&path.",path);
put 'NOTE: ' path=;
call execute(cats('%nrstr(%impt(',path,',',i,'));'));
end;
stop;
run;
data all;
set XL:;
run;
*********** ERROR LOG ******************
ERROR: Insufficient authorization to access PIPE.
command=dir E:\Lev1\Data\1_INPUTDOCS\IMPDOC\*.xlsx /b eof=0 i=. path= _ERROR_=1 _N_=1
NOTE: The SAS System stopped processing this step because of errors.
NOTE: DATA statement used (Total process time):
real time 0.03 seconds
cpu time 0.01 seconds
41
42 data all;
43 set XL:;
ERROR: The data set list (WORK.XL:) does not contain any members.
44 run;
Please run PROC OPTIONS to verify that XCMD is set.
I ran it. Got a list and 1 of the entries was:
NOXCMD Disables the X command in SAS.
Okay please enable XCMD option to use pipe command,
your SAS Admin might help you on this.
Refer this link, it will give you clear explanation why we have to enable XCMD option before using pipe command:
If you don't have permissions to change XCMD setting, which is highly likely, consider alternatives.
Theres a task that should list all files and see the directory traversal example here
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.