Could you let me know how to delete the log files from the Logs Folder in SAS which are older than 1 month.
Currently i am manually deleting the files from this folder.
Is there a SAS job which can be written or any script which can be auto triggered ?.
A solution depends on the os of the sas server. On a windows server i would use something like the solution posted on https://stackoverflow.com/questions/17829785/delete-files-older-than-15-days-using-powershell.
Also wanted to know whether it can be done through SAS jobs in DI studio.
DI Studio is just generating and executing SAS code.
If XCMD is set you can execute OS level commands via SAS.
Proc Options option=xcmd; run; will tell you what's set.
IF your compute server where SAS executes is Unix/Linux then what you want can be done with a single command (Unix find ) that you then can call out of SAS via Filename pipe or system()/call system();
Using DIS just a single node with user written code.
See this piece of SAS code which extracts the modification timestamp for files in a directory:
data times; length dref fref $8 fname $200; rc = filename(dref,"name of your logs directory"); did = dopen(dref); if did then do; do i = 1 to dnum(did); fname = dread(did,i); rc = filename(fref,cats("~/",fname)); fid = fopen(fref); if fid then do; modified = input(finfo(fid,foptname(fid,5)),nldatm30.); rc = fclose(fid); output; end; rc = filename(fref); end; rc = dclose(did); end; rc = filename(dref); format modified e8601dt19.; drop dref fref rc did fid i; run;
From this dataset, you can then run a data step which uses the FDELETE Function (if you're comfortable with the code once you tested it, you can add the FDELETE immediately before the OUTPUT).
The SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment.
Learn how to install the SAS Viya CLI and a few commands you may find useful in this video by SAS’ Darrell Barton.
Find more tutorials on the SAS Users YouTube channel.