Hi all,
I want to delete the folders (want to keep 5 days folders only).
my code is creating folders every day yymmdd10. format.
but I want to keep only 5 days folders only.
my folders are like this
20180419
20180420
20180421
20180423
20180424
20180425
20180426
20180427
20180428
20180429
20180430
Thanks,
SS.
Something like (and you don't mention which os you use so windows assumed):
http://support.sas.com/kb/45/805.html
Filename filelist pipe "dir /b /s c:\temp\*.sas"; Data _null_; Infile filelist truncover; Input filename $100.; if _n_>5 then call execute(cats('%sysexec(del c:/temp/"',filename,'");')); Run;
You can change the if as you like, maybe input as date and check if date is today()-5 or less.
It is windows.
I want to delete the folders irrespective of files in those folders.
Below filename statement referring .sas files.
Filename filelist pipe "dir /b /s c:\temp\*.sas";
see the attached
I am not opening zip files.
Just change the filename to point to your area, i.e replace c:/temp with where your folders are located:
Filename filelist pipe "dir /b /s /ad c:\temp\";
Note I added /ad to restrict list to directories only.
Thank you,
I think,I have an issue with my sas shortcut.
NOTE: The infile FILELIST is:Unnamed Pipe Access Device,PROCESS=dir /b /s C:\test\.
Thanks,
SS
I don't know what "I think,I have an issue with my sas shortcut." means? The note seems correct, assuming all your folders are in c:/test. Note your missing the /ad, which only gets directories.
You need XCMD enabled to use PIPE commands or to use system commands.
options xcmd;
If that errors out, you'll need a different method, most likely using FDELETE instead. It's still possible, just a different approach required.
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.
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.