DATA Step, Macro, Functions and more

X Statement, Call System and Named Pipe

Reply
New Contributor
Posts: 3

X Statement, Call System and Named Pipe

I realize that all three options can allow a SAS user to pass system command to the operating system for execution. I wonder the differences among three methods and their pros and cons.

I normally use named pipe to redirect the results as the source of the infile. But, I usually use X (anywhere in SAS) and Call System in the data step.

But, I saw people use named pipe to execute "DEL" commaind in Windows insead using X command.

Thanks for the help!
Respected Advisor
Posts: 4,173

Re: X Statement, Call System and Named Pipe

Posted in reply to ReilingLee
And there would also be SYSTASK() and %SYSTASK() which I like especially under UNIX as it allows you to choose the shell. Message was edited by: Patrick
PROC Star
Posts: 7,489

Re: X Statement, Call System and Named Pipe

Posted in reply to ReilingLee
I think that the biggest differences bewteen the two are that, with a pipe, you can communicate both ways bewteen SAS and the program or call you are executing.

A nice summary of possible uses of pipes can be found in the following SGF paper:
http://www2.sas.com/proceedings/forum2008/092-2008.pdf

Pipes are also nice in that you don't have to change your system options like noxwait, xsync, etc.

However, when you don't have to communicate both ways, they require an extra step in that you have to first declare them, and then use them.

HTH,
Art
New Contributor
Posts: 3

Re: X Statement, Call System and Named Pipe

Posted in reply to ReilingLee
I took a quick look at the paper. I see the benefits using named pipe in Example 1, 2, and 3 because the substep reads the results and processes them.

In example 4, does it have any benefits over X statement?
Respected Advisor
Posts: 3,799

Re: X Statement, Call System and Named Pipe

Posted in reply to ReilingLee
Indeed there is little difference when a command like MKDIR is executed through a PIPE.

Using a pipe might be preferred over X as X may cause a DOS box to pop up. There are options for that but with PIPE you don't need them.

You might also consider using the DCREATE function for directory creation.

[pre]
x "mkdir test%sysfunc(left(%sysfunc(datetime(),16.3)))";

data _null_;
length command $128;
command = cats('mkdir test',put(datetime(),16.3-L));
infile dummy pipe filevar=command;
run;

data _null_;
path = dcreate(cats('test',put(datetime(),16.3-L),'.'));
putlog 'NOTE: ' PATH=;
run;
[pre]
Ask a Question
Discussion stats
  • 4 replies
  • 148 views
  • 0 likes
  • 4 in conversation