DATA Step, Macro, Functions and more

Insufficient authorization to access PIPE - need alternatives

Reply
Super Contributor
Posts: 426

Insufficient authorization to access PIPE - need alternatives

I would appreciate if someone can provide me the alternatives for the following statement which should run in SAS EG 5.1?

Log below indicates that filename statement is unsuccessful.

filename indat1 pipe  'ls -d /data/Resource/Alert/daily_files/*'  ;

ERROR: Insufficient authorization to access PIPE.

ERROR: Error in the FILENAME statement.

Super User
Posts: 10,550

Re: Insufficient authorization to access PIPE - need alternatives

If you can enter the ls -d /data/Resource/Alert/daily_files/* from a command line and get a successful listing then you may have an issue with the configuration of SAS. You may need to provide some details of your environment such as are you working with a server based version of SAS. If the data folder isn't subordinate to the location of the SAS current directory then it can't find it. It is a good idea to always provide a full path in a libname statement, which may need to include reference to the server the file is on.

If the command line doesn't work then it is likely an OS issue or possibly a typo for the path.

Super Contributor
Posts: 426

Re: Insufficient authorization to access PIPE - need alternatives

I could succeed the command ls -d /data/Resource/Alert/daily_files/* from command line (UNIX server). Yes, I'm working in a server based SAS and there is no typo in my path name.

Super User
Posts: 6,972

Re: Insufficient authorization to access PIPE - need alternatives

You are most likely operating under the -noxcmd restriction. This has to be corrected in the metadata for the workspace server.

If you can't get your admin to to it, but have the option of command line access, I suggest you run the program in batch mode. Which would prove the idiocy of keeping noxcmd to the admin.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super Contributor
Posts: 426

Re: Insufficient authorization to access PIPE - need alternatives

May i request you to guide me to run my command (as mentioned in my initial post) in SAS EG via batch mode?

Super User
Posts: 6,972

Re: Insufficient authorization to access PIPE - need alternatives

You take your code as written (be aware for EG-specific things like ODS output to the EG channel) and save it to your server under "Files". In most setups this is the home directory you find yourself in when logging on via ssh (or telnet).

Then log on to the server and simply do sas programname.sas. The run will create programname.log (and programname.lst if you have output). Inspect the log file to see if it worked or what went wrong. Make changes to the code and save again, repeat until satisfactory.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Valued Guide
Posts: 3,208

Re: Insufficient authorization to access PIPE - need alternatives

Please explain your situation as it can be:

1/ your system-admin sas-admin doesn't like you or your are classified by them as a jerk. Is there a bypass for that?

This question is: how well do you know those guys and are you on speaking terms.

2/ Those people having done the sas-installations were just capable of typing a "setup" command. Not cooperating with your business needs. How do you solve that?

This is the service manager, project manager to coordinate but that fails when missing some input on your business needs and sas knowledge aside all internal politics.

One of the to be solved questions in this implementing a good security approach including the OS level controls. 

These are the reason why the xcmd is left closed.  Having no real OS security defined this is the last thing on not granting functions for that level.   

You could try this having it solved now you know this. (open up xcmd !)

If you have access to the relevant business security policies you could ask to how those arer related against eg ISO 27002-2013 9.4.1 as there is explicitly stated those controls are aimed at user actions to sensitive data not at using some functionality/tool.    the 9.4.4 is mentioning priviledged utilty programs, imo sas is not that (common sas users)


When you are coding something to process files in sas you can:

- use wildacards in namings. the real filename is returned

- use dopen functions the build a directory list with all information just using sas functions

  SAS(R) 9.4 Functions and CALL Routines: Reference, Third Edition

---->-- ja karman --<-----
SAS Employee
Posts: 15

Re: Insufficient authorization to access PIPE - need alternatives

You can try the following:

data dirs(keep=path name);

length name $ 200 path $ 200;

rc=filename('di','/data/Resource/Alert/daily_files/');

did=dopen('di');

memcnt=dnum(did);

do i = 1 to memcnt;

name=dread(did,i);

path=catt(pathname('di'),'/',name);

rc=filename('f',catt(pathname('di'),'/',name));

did1=dopen('f');

if did1 then output;

rc=dclose(did1);

end;

rc=dclose(did);

run;

Super Contributor
Posts: 426

Re: Insufficient authorization to access PIPE - need alternatives

Thanks for the response.

I ran your code, but I don't see any differences  in the directory. See log below.

14         GOPTIONS ACCESSIBLE;

15         data dirs(keep=path name);

16         length name $ 200 path $ 200;

17         rc=filename('di','/data/Resource/Alert/daily_files/');

18         did=dopen('di');

19         memcnt=dnum(did);

20         do i = 1 to memcnt;

21         name=dread(did,i);

22         path=catt(pathname('di'),'/',name);

23         rc=filename('f',catt(pathname('di'),'/',name));

24         did1=dopen('f');

25         if did1 then output;

26         rc=dclose(did1);

27         end;

28         rc=dclose(did);

29         run;

NOTE: The data set WORK.DIRS has 0 observations and 2 variables.

NOTE: DATA statement used (Total process time):

      real time           0.02 seconds

      cpu time            0.01 seconds

SAS Employee
Posts: 15

Re: Insufficient authorization to access PIPE - need alternatives

Whats the output of 'ls -d /data/Resource/Alert/daily_files/*' ?

Super User
Super User
Posts: 7,430

Re: Insufficient authorization to access PIPE - need alternatives

Not sure if there is a Unix equivalent as don't use it at the moment.  However in DOS you can simply direct the output to a text file and then read that in:

dir c:\temp>my_dir.txt

Pop that in a batch file, run it and then run your SAS program to read that text file.

Super User
Posts: 9,691

Re: Insufficient authorization to access PIPE - need alternatives

Check this. But I would like to use OS command.

http://support.sas.com/kb/25/074.html

Super Contributor
Posts: 426

Re: Insufficient authorization to access PIPE - need alternatives

Thanks.

So can we the code (tweaking to match to my folders) provided in the link to match with my initial code filename indat1 pipe  'ls -d /data/Resource/Alert/daily_files/*' ; for successful run in EG?

Super User
Posts: 9,691

Re: Insufficient authorization to access PIPE - need alternatives

It is a macro . replace its parameter as you will .

%macro drive(dir,ext); 
  
  %let filrf=mydir; 
  
  /* Assigns the fileref of mydir to the directory and opens the directory */ 
  %let rc=%sysfunc(filename(filrf,&dir)); 
  %let did=%sysfunc(dopen(&filrf)); 
  
  /* Returns the number of members in the directory */ 
  %let memcnt=%sysfunc(dnum(&did)); 
  
  /* Loops through entire directory */ 
  %do i = 1 %to &memcnt; 
  
  /* Returns the extension from each file */ 
  %let name=%qscan(%qsysfunc(dread(&did,&i)),-1,.); 
  
  /* Checks to see if file contains an extension */ 
  %if %qupcase(%qsysfunc(dread(&did,&i))) ne %qupcase(&name) %then %do; 
  
  /* Checks to see if the extension matches the parameter value */ 
  /* If condition is true prints the full name to the log */ 
  %if (%superq(ext) ne and %qupcase(&name) = %qupcase(&ext)) or 
  (%superq(ext) = and %superq(name) ne) %then %do; 
  %put %qsysfunc(dread(&did,&i)); 
  %end; 
  %end; 
  %end; 
  
  /* Closes the directory */ 
  %let rc=%sysfunc(dclose(&did)); 
  
%mend drive; 

%drive( /data/Resource/Alert/daily_files/)

Valued Guide
Posts: 3,208

Re: Insufficient authorization to access PIPE - need alternatives

Babloo, unless you solved your xcmd setting with your admins, you can forget using pipe or any other OS commands from SAS on the Unix server (EG is more like a browser terminal). That is where you started with the error message, "ERROR: Insufficient authorization to access PIPE." 

---->-- ja karman --<-----
Ask a Question
Discussion stats
  • 14 replies
  • 1917 views
  • 3 likes
  • 7 in conversation