BookmarkSubscribeRSS Feed
RensMeerman
Calcite | Level 5

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;

 

4 REPLIES 4
Kalind_Patel
Lapis Lazuli | Level 10

Please run PROC OPTIONS to verify that XCMD is set.

 

RensMeerman
Calcite | Level 5

I ran it. Got a list and 1 of the entries was:

 

NOXCMD Disables the X command in SAS.

 

Kalind_Patel
Lapis Lazuli | Level 10

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:

http://support.sas.com/documentation/cdl/en/hostwin/69955/HTML/default/viewer.htm#p0xtd57b40ehdfn1jy...

Reeza
Super User

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

 

http://www2.sas.com/proceedings/forum2007/008-2007.pdf

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

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.

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
  • 4 replies
  • 1126 views
  • 0 likes
  • 3 in conversation