BookmarkSubscribeRSS Feed
lacrefa
Calcite | Level 5

Dear

You can have a look on this type of code, include it inside a macro program :

It test if the file exist and backup it .

 

%let file_src=&original_path./my_file.txt;
%let flag_csc_exist=NO;
data _null_;
fname="tempfile";
rc=filename(fname,"&file_src");
if rc = 0 and fexist(fname) then call symput ('flag_csc_exist','YES');
rc=filename(fname);
run;


%if &flag_csc_exist eq YES %then %do;
%put I must move the file ;
%let file_src_ar=&original_path./archive/my_file.txt_%TRIM(%QSYSFUNC(DATE(), YYMMDDN8.));
filename src_file "&file_src";
filename tgt_file "&file_src_ar";
data _null_;
  infile src_file;
  file tgt_file;
  input;
  put _infile_;
run;
filename src_file clear;
filename tgt_file clear;
%end;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 15 replies
  • 4008 views
  • 5 likes
  • 9 in conversation