BookmarkSubscribeRSS Feed
ReilingLee
Calcite | Level 5
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!
4 REPLIES 4
Patrick
Opal | Level 21
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
art297
Opal | Level 21
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
ReilingLee
Calcite | Level 5
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?
data_null__
Jade | Level 19
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]

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1308 views
  • 0 likes
  • 4 in conversation