BookmarkSubscribeRSS Feed
annypanny
Quartz | Level 8
sure, how can I move a dataset in to different location?
By using X command?
annypanny
Quartz | Level 8
And how can I delete a file if it's age is more than 30 days?
Kurt_Bremser
Super User

The documentation for the FDELETE function is just one down from the one for FCOPY. Everything else is just a matter of conditions and date calculations, read: basic data step programming.

kelxxx
Quartz | Level 8
/*Where the files in*/
%let repfic=H:\;

/*Where to move*/
%let repmove=H:\Batch;

/*ficrep contains all files name in the &refic*/
FILENAME ficrep PIPE "dir /b &repfic";

/*create table SAS = ficrep, it is necessary if in ficrep have the other file*/
data toto;
infile ficrep end=eof;
length x $50;
input x;
run;


/*traitement*/
data tata;  /*data _null_;*/
set toto(where=(x like "online%"));
length _repname _repmove $200;

_y=put(date(),yymmddN.); /*date today 20200414*/
_over30=put(date()-30,yymmddN.); /*date aged 30day 20200315*/
_datex=substr(x,11,8);			/*date in filename*/
_repname=cats("&repfic",x);		/*H:\onlineuseryyyymmdd.txt*/
_repmove=catx(" ",x,"&repmove");	/* onlineuseryyyymmdd.txt H:\batch*/

if _datex le _over30 then do;
delete=1;						/*if file aged over 30 days */
Call system(catx(" ","del /Q",_repname));	/*execute a command line windows del /q H:\onlineuseryyyymmdd.txt */
end;										/*    = suppress the file*/
if _datex = _y then do;
move=1;
call system(cats("move /Y &repfic\",_repmove));	/*move /y h:\onlineuseryyyymmdd.txt H:\batch*/
end;												/* move the file to the path spécified*/
drop _:;
run;

I'm not sure thit is what you want but i hope this can help you.

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
  • 20 replies
  • 2521 views
  • 9 likes
  • 5 in conversation