BookmarkSubscribeRSS Feed
ehsanmath
Obsidian | Level 7

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
7 REPLIES 7
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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

 

ehsanmath
Obsidian | Level 7

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

I check again, my SAS is running on Windows.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

Ksharp
Super User

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;

ehsanmath
Obsidian | Level 7

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

Ksharp
Super User

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.

LinusH
Tourmaline | Level 20

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

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