Hi all:
Can anybody tell me why this works:
data _null_;
x dir p:\sas\data\*.txt > p:\sas\data\test.txt ;
run;
but this doesn't:
data _null_;
x ping www.google.ca > p:\sas\data\pingtest.txt ;
run;
I have OPTION XWAIT so I need to close the X window when it opens in the first example, but in the second example, the window opens and closes right away - tooo fast to see any messages or errors (if any).
I can enter the command from a CMD window and it works.
Thanks in advance.
Good question! I don't know why it doesn't work, but I can offer a work-around. It worked for me when I submitted the command using a pipe. What I ran was:
Filename pinginf pipe "ping www.google.ca" ;
Filename pingout "c:\art\pingout.txt";
data _null_;
infile pinginf pad ;
file pingout;
input dsn $50. ;
put dsn;
run;
Art:
(How's it goin', eh?)
I tried the pipe, and I also got it to work by using the X command to run a .BAT file that contains the PING command.
Really odd that it won't run the PING from the X command itself. Wonder if anyone from SAS knows whats up?
Joe Matise, over on SAS-L, suggested an interest combination of quotes that worked:
x '"ping www.google.ca" > c:\ping2.txt';
Let me know if that works for you.
Otherwise, the > symbol is apparently being considered a parameter rather than an argument. Also, having to specify it this way won't accept rerouted aliases. Thus, in the US, www.google.ca won't work using this method.
and, from SAS-L as well, Bolotin Yevgeniy offered a solution that is less finicky:
x "cmd /c ping www.google.ca > c:\pipe3.txt";
Of course, he also stated that with this method if you are not on windows, you would have to use the appropriate shell commands for your OS
Nice find! Doesn't explain it, though, other than SAS has known about it since 2003.
How did you find the note? After seeing your post I did a google search for:
"note" "PING command might not work" site:support.sas.com
with the result:
No results found for "note" "PING command might not work" site:support.sas.com.
Hi. Art.
I input " x ping " at support.sas.com. and got it.
Ksharp
This is nearly exactly what I had to do.
Thanks all - didn't expect so much help.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.