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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

Develop Code with SAS Studio

Get started using SAS Studio to write, run and debug your SAS programs.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 981 views
  • 1 like
  • 3 in conversation