06-04-2017 08:29 PM
I would like to move .txt files from one folder to another .
The txt files are like ab001.D170605.EDLY.txt
the following code is not working
%put x mv "&fpath/AB001.D&tdate..EDLY.TXT" &apath.;
x mv "&fpath/ET001.D&tdate..EDLY.TXT" &apath.;
where fpath = source location
06-04-2017 08:35 PM
Steps to debug this:
1. Does it work in command line
2. Does it work without macros
3. Does it work with basic skeleton macro
4. What does not work mean?
06-04-2017 09:57 PM
06-04-2017 10:29 PM
could you please try the below code without the quotes to the path mentioned within the x command after the mv command
x "mv /data/DEVELOPMENT/LANDING/IN_FILES/ET001.D170605.EDLY.TXT /data/DEVELOPMENT/LANDING/ARCHIVED_IN";
06-04-2017 10:51 PM
06-05-2017 12:00 AM
That is why I always call operating system commands using PIPE instead of using X or %SYSEXEC. When you call the command using an INFILE with PIPE engine you can read the response from the operating system. If you had done that here you would have seem right away that the operating system did not understand the move command.
1 data _null_; 2 infile "move x y" pipe ; 3 input; 4 put _infile_; 5 run; NOTE: The infile "move x y" is: Pipe command="move x y" /bin/ksh: move: not found NOTE: 1 record was read from the infile "move x y". The minimum record length was 25. The maximum record length was 25.
06-05-2017 12:14 AM
06-05-2017 12:18 AM
@arunasaran Once tdate was defined it worked correctly for me.
So define tdate. And post your code using the editor and take some time to format the question. We take the time to answer your questions but it's easier if you organize your process clearly from the beginning.
%let tdate = %sysfunc(today(), yymmdd6.); %put &tdate;
06-04-2017 11:57 PM
Tried the following and its working:
x "mv /data/DEVELOPMENT/LANDING/IN_FILES/ET002A.D170605.EDLY.TXT /data/DEVELOPMENT/LANDING/ARCHIVED_IN";
But I would like to use the macros for location and tdate of the file as:
x "mv &fpath/ET002A.&tdate..EDLY.TXT &apath";
where &tdate is todays date