DATA Step, Macro, Functions and more

Obtaining "Shell Output" in sas with SAS function "System", "X" or "Call System"

Reply
Contributor
Posts: 34

Obtaining "Shell Output" in sas with SAS function "System", "X" or "Call System"

Hallo,

 

Is there any way in sas to obtain Shell output inside SAS. For example, I am trying to obtain the output of Unix Shell command "top" (which is in the attached). Is there any way to do it in SAS ? I have seen command line calls can be executed using the sas functions like "System()" or "X". But the Question is to get the output inside SAS along with the executon.

 

Thanks and regards

Ehsan


Output_of_TOP.jpg
Super User
Super User
Posts: 7,399

Re: Obtaining "Shell Output" in sas with SAS function "System", "X" or

Set your OS command as a filename, then datastep read it in, in this example I use the Windows, and below I make an attempt to show the top even though I don't use Unix:

filename mytmp pipe 'dir "c:\temp" /b';

data dir_list;
  length buffer $200;
  infile mytmp dlm="¬";
  input buffer;
run;
filename mytmp pipe 'top';
data ...

 

Contributor
Posts: 34

Re: Obtaining "Shell Output" in sas with SAS function "System", "X" or

whats the equivalant to "top" in Windows (DOS) ?

I check again, my SAS is running on Windows.

Super User
Super User
Posts: 7,399

Re: Obtaining "Shell Output" in sas with SAS function "System", "X" or

You could try the mem command:

http://www.computerhope.com/memhlp.htm

 

You may be better off getting some system monitor sotware though, more functionality/control.

Super User
Posts: 9,676

Re: Obtaining "Shell Output" in sas with SAS function "System", "X" or

Another way is to redirect the output of Shell Command into a file :

$ls *.csv  >  /home/etc/output.txt

 

and then import it into SAS:

filename x '/home/etc/output.txt';

data _null_;

 infile x;

 input;

 put _infile_;

run;

Contributor
Posts: 34

Re: Obtaining "Shell Output" in sas with SAS function "System", "X" or

Actually, I am thinking to monitor RAM and CPU Usage inside SAS during computation. Is it possible ?

Super User
Posts: 9,676

Re: Obtaining "Shell Output" in sas with SAS function "System", "X" or

I can't test it . so I can't say YES. 

My thought is setting up a schedule task , launch it at every hour or half-hour, and run the SAS script we just suggested.

Super User
Posts: 5,256

Re: Obtaining "Shell Output" in sas with SAS function "System", "X" or

Not sure how you wish to do that? In the same SAS session? Don't think that's possible, and why?

SAS interacts/uses system resources so monitoring should take place outside SAS.

For statistical purposes, you could use SAS to collect the figures, like options fullstimer, or ARM stuff.

Data never sleeps
Ask a Question
Discussion stats
  • 7 replies
  • 426 views
  • 0 likes
  • 4 in conversation