BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
OS2Rules
Obsidian | Level 7

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.

1 ACCEPTED SOLUTION

Accepted Solutions
8 REPLIES 8
art297
Opal | Level 21

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;

OS2Rules
Obsidian | Level 7

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?

art297
Opal | Level 21

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.

art297
Opal | Level 21

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

Ksharp
Super User

Maybe you need this:

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

Ksharp

art297
Opal | Level 21

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.

Ksharp
Super User

Hi. Art. Smiley Happy

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

Ksharp

OS2Rules
Obsidian | Level 7

This is nearly exactly what I had to do.

Thanks all - didn't expect so much help.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

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.

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
  • 8 replies
  • 1608 views
  • 3 likes
  • 3 in conversation