Help using Base SAS procedures

X Command Question

Accepted Solution Solved
Reply
Super Contributor
Posts: 358
Accepted Solution

X Command Question

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.


Accepted Solutions
Solution
‎11-17-2011 10:27 PM
Super User
Posts: 10,020

X Command Question


All Replies
PROC Star
Posts: 7,468

X Command Question

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;

Super Contributor
Posts: 358

X Command Question

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?

PROC Star
Posts: 7,468

X Command Question

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.

PROC Star
Posts: 7,468

X Command Question

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

Solution
‎11-17-2011 10:27 PM
Super User
Posts: 10,020

X Command Question

Maybe you need this:

http://support.sas.com/kb/10/899.html

Ksharp

PROC Star
Posts: 7,468

X Command Question

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:

Information No results found for "note" "PING command might not work" site:support.sas.com.

Super User
Posts: 10,020

X Command Question

Hi. Art. Smiley Happy

I input "  x ping " at support.sas.com. and got it.

Ksharp

Super Contributor
Posts: 358

X Command Question

This is nearly exactly what I had to do.

Thanks all - didn't expect so much help.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 8 replies
  • 270 views
  • 3 likes
  • 3 in conversation