BookmarkSubscribeRSS Feed
Aidas
Calcite | Level 5

Hi,

 

I'm trying to set up some basic disk space monitoring for our SAS Studio users (SAS version 9.04.01M6P110718). Below I've copied the code which checks the free space on the server disk and outputs it using proc print. It works fine, but I would like to include it in autoexec for each user to see when they log into SAS Studio. I copied the code into "Edit Autoexec File" window and tried to reset my sas session. The code worked except the proc print. I can see the tables created in the work library, but no printed results appear.

 

- Why is proc print not working in autoexec, is there a solution for that?

- How can I include this code in autoexec for all users, not just myself?

 

Thanks

 

%let csvdata = %sysfunc(pathname(work))\wmic_output.csv;

filename wmic_csv "&csvdata" encoding="utf-16";
filename gather pipe "wmic logicaldisk get name,size,freespace /format:csv"; 

* process the wmic command and strip off blank first row and extraneous CR character at end of line;
data _null_;
  infile gather; 
  input;
  if _n_ > 1;
  _infile_ = compress(_infile_, '0d'x);
  file wmic_csv;
  put _infile_;
run;

proc import replace out=diskinfo file=wmic_csv dbms=csv;
run;

data diskinfo2 (keep=space free pct_free);
	set diskinfo;
	where name='D:';
	
	freespace=freespace/1024/1024/1024;
	size=size/1024/1024/1024;
	
	space=put(size,4.)!!' GB';
	free=put(freespace,4.)!!' GB';
    
    format pct_free percent10.;
	pct_free=freespace/size;
run;

proc print data=diskinfo2;
run;
2 REPLIES 2
Amir
PROC Star

Is a log generated, and if so, what does it contain?

Kurt_Bremser
Super User

The routing of output is done separately for every single piece of code (task) that is executed. You can (not) see that in the log (code was run in SAS Studio, 9.4M6 on an AIX server):

 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 72         
 73         proc print data=sashelp.class;
 74         run;
 
 NOTE: There were 19 observations read from the data set SASHELP.CLASS.
 NOTE:  Verwendet wurde: PROZEDUR PRINT - (Gesamtverarbeitungszeit):
       real time           0.06 seconds
       cpu time            0.04 seconds
       
 
 75         
 76         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 88        

The lines between 2 and 71 contain, among a lot of other things, code to set up ODS output to a file that is later read by Studio or Enterprise Guide (both are "IOM clients") to retrieve the results; similar for lines 77 to 87, where the ODS destinations are closed.

Since the autoexec.sas file is executed by the workspace server before it sets up the IOM connection, there is no way for the output to make it back to SAS Studio.

 

Enterprise Guide provides code that is run whenever a server connection is established, but SAS Studio does not have such an option.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 2 replies
  • 459 views
  • 1 like
  • 3 in conversation