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;

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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
  • 4445 views
  • 5 likes
  • 9 in conversation