I have 10 files in one directory in FTP which has to be moved to another directory in FTP. For file move process I'm using Fcopy.
For all the 10files -starting of the filename is common (Report), Only the datepart and endpart of the file changes every month. I defiend datepart and endpart of the filenames to macro as the endpart of the filename are saved in table data as fname.
Filename examples :
1. Report_31-10-2018_wind.xlsx
2. Report_31-10-2018_water.xlsx etc.
Dataset : Data
fname
wind
water
health
.
.
.
proc sql;
select count(fname) into:n trimmed from data;
select distinct fname into:fn1 - :fn%left(&n)
from data;
run;
data _null_;
call symput ('datepart',put(intnx('month',today(),0,"b"),yymmdd10.));
run;
data _null_;
length msg $384;
i=filename('in',"/temp/files/Report&datepart._&&fn&n..xlsx", "DISK", "RECFM=N");
o=filename('out',"/temp/files/backup/Report&check._&&fn&n..xlsx", "DISK", "RECFM=N");
rc=fcopy('_in', '_out');
if rc=0 then
put 'Copied _in to _out.';
else do
msg=sysmsg();
put rc= msg=;
end;
i=filename('in');
o=filename('out');
run;This code works perfect without errors. But moves only 1 file ie., fn10 file but not rest of the files.
Can any advice what I'm missing here.
Can I define it as following
%macro fend;
%do i=1 %to 5;
%put filename=&&fn&i;
%end;And use fend instead of &fn&n in following statement?
i=filename('in',"/data/skynet/files/custom_billing/Cat/NSMIS/BNC/&cname&check._&fend..xlsx", "DISK", "RECFM=N");
Thanks, for the advice,
I was over think for the simple solution 🙂
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.