BookmarkSubscribeRSS Feed
santosh_pat69
Quartz | Level 8

Hi All,

 

I am trying to keep only the last 7 days output and the input files used or created  by a  SAS process.

 and i am using the below mentioned command, but i see that all the output files created and the Input files for the SAS process.

 

data _Null_;

x "cd &Inpth.";

x "find &Inpth. -type f -mtime +7 -print | xargs rm";

run;

 

 

Regards,

Santosh

2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Well, you haven't mentioned what any of the macro variables are?  As for this kind of process when you are determining file date, it is not as straight forward, changing your system clock for instance is one simple way to mess this up.  Generally I would ask IT to setup some sort of file clean on a regular basis.

As for your code, the find dos command searches in a file for text, how are you intending using that for file dates?

 

If they are SAS files, then you should be able to pull dates of files from the SAS metadata - sashelp for instance.  If not then as simple dir can give you the info:

filename tmp pipe 'dir "<path>\*.*"';
data dirlist;
  length buff $200;
  infile tmp;
  input buff $;
run;

Do be aware that if run on various machines/os's you would need to handle that, and different date formats etc.  Basically its more complicated than you think, so let IT use their tools (or if there are SAS tools you can use for example session cleaners are present in some SAS products).

SAS Innovate 2025: Call for Content

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!

Submit your idea!

How to Concatenate Values

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.

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
  • 957 views
  • 0 likes
  • 3 in conversation