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-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!

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.

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
  • 946 views
  • 0 likes
  • 4 in conversation