Hi,
my user folder is getting cluttered by hundreds of plots and histograms. When I close SAS, the folder is not emptied, and I have to do it manually.
Is there an option to force SAS to clean the user area from temporary plots?
I am using SAS 9.4
Thanks!
@gabonzo wrote:
Still, I would prefer to have SAS do a proper cleaning on it own 😉
You could set the default path for those files to the WORK folder, which in general (as you know) is automatically deleted at the end of a SAS session. Again, the autoexec.sas would be a suitable place for a statement such as
ods listing gpath="%sysfunc(pathname(WORK))";
(For HTML files, if any, there is a checkbox "Use WORK folder" in Tools --> Options --> Preferences... --> Results.)
If you can run X statements or %sysexec you might just write a small program line or two and put it in your autoexec.sas file
Something like
x 'del c:\pathtouserlibrary\*.png'
x 'del c:\pathtouserlibrary\*.html'
or have that as an autocall macro to call when needed
@gabonzo wrote:
Still, I would prefer to have SAS do a proper cleaning on it own 😉
You could set the default path for those files to the WORK folder, which in general (as you know) is automatically deleted at the end of a SAS session. Again, the autoexec.sas would be a suitable place for a statement such as
ods listing gpath="%sysfunc(pathname(WORK))";
(For HTML files, if any, there is a checkbox "Use WORK folder" in Tools --> Options --> Preferences... --> Results.)
Ok, but please help me here:
I looked in the Tools --> Options --> Preferences... --> Results window, and the "Use WORK folder" checkbox was already set.
I still get the results html file in the user folder, what am I doing wrong?
@gabonzo wrote:
Ok, but please help me here:
I looked in the Tools --> Options --> Preferences... --> Results window, and the "Use WORK folder" checkbox was already set.
I still get the results html file in the user folder, what am I doing wrong?
The options list check box for results is basically setting the behavior for the one level data set name. If you have a USER library then one level names go there, not the actual WORK library. And USER libraries don't get cleaned. I did find that if you uncheck "Use Work folder" and change active directories frequently you can end up with HTML and PNG scattered all over your drive.
If you do not want HTML files in the USER library you would have to do something else. I haven't quite figured out a real good alternative. You could send ALL of your HTML to another specific folder but it would not get cleaned up either but they won't be in the USER library. Just set a specific path under the Create HTML and uncheck the "use work folder" I basically don't worry about it much and just clean up my USER library with a script periodically.
Ok, I think I got it. If you use:
ods html gpath="%sysfunc(pathname(WORK))";
Then the image files are sent to the work directory, but the HTML file is sent to the user directory.
If you instead use:
ods html path="%sysfunc(pathname(WORK))";
Then both the HTML file and the images are sent to the work directory. You could specify different path and gpath if you wanted to, but it's not what I need here.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.